def deactivate(self)"sets this button to 'inactiveself label setfill('darkgrey'self rect setwidth( self active false of coursethe main point of button is being able to determine if it has been clicked let' try to write the clicked method as you knowthe graphics package provides getmouse method that returns the point where the mouse was clicked if an application needs to get button clickit will first have to call getmouse and then see which active button (if anythe point is inside of we could imagine the button processing code looking something like the followingpt win getmouse(if button clicked(pt)do button stuff elif button clicked(pt)do button stuff elif button clicked(ptdo button stuff the main job of the clicked method is to determine whether given point is inside the rectangular button the point is inside the rectangle if its and coordinates lie between the extreme and values of the rectangle this would be easiest to figure out if we just assume that the button object has instance variables that record the min and max values of and assuming the existence of instance variables xminxmaxyminand ymaxwe can implement the clicked method with single boolean expression def clicked(selfp)"returns true if button is active and is insidereturn (self active and self xmin < getx(<self xmax and self ymin < gety(<self ymaxhere we have single large boolean expression composed by anding together three simpler expressionsall three must be true for the function to return true value the first of the three subexpressions simply retrieves the value of the instance variable self active this ensures that only active buttons will report that they have been clicked if self active is falsethen clicked will return false the second two subexpressions are compound conditions to check that the and values of the point fall between the edges of the button rectangle (rememberx < < means the same as the mathematical expression < < (section )now that we have the basic operations of the button ironed outwe just need constructor to get all the instance variables properly initialized it' not hardbut it is bit tedious here is the complete class with suitable constructor