def makecoloredrect(cornerwidthheightcolorwin)''return rectangle drawn in win with the upper left corner and color specified ''corner corner clone(corner move(width-heightrect rectangle(cornercorner rect setfill(colorrect draw(winreturn rect def getchoice(choicepairsdefaultwin)#new '''given list choicepairs of tuples with each tuple in the form (rectanglechoice)return the choice that goes with the rectangle in win where the mouse gets clickedor return default if the click is in none of the rectangles ''point win getmouse(for (rectanglechoicein choicepairsif isinside(pointrectangle)return choice return default def main()win graphwin('pick colors' win yup(#new choicepairs list(buttonsetup [( 'red')( 'yellow')( 'blue')for (xycolorin buttonsetupbutton makecoloredrect(point(xy) colorwinchoicepairs append((buttoncolor)house makecoloredrect(point( ) 'gray'windoor makecoloredrect(point( ) 'white'winroof polygon(point( )point( )point( )roof setfill('black'roof draw(win#new shapepairs [(house'house')(door'door')(roof'roof')msg text(point(win getwidth()/ ),''msg draw(winfor (shapedescriptionin shapepairsprompt 'click to choose description color msg settext(promptcolor getchoice(choicepairs'white'winshape setfill(colorwin promptclose(msgmain(run it with the limited number of choices in choosebutton pythe change in length to convert to choosebutton py is not significantbut the change in organization is significant if you try to extend the pro more on flow of control