Question: import time from tkinter import * from random import randint class ButtonWrapper: def ( self , id = ' , row = -

import time
from tkinter import *
from random import randint
class ButtonWrapper:
def (self, id=""', row=-1, col=-1,c="):
self.ID = id
self. ROW = row
self. COL = COL
self. COLOR =C
self.BUTTON_OBJ = None
Check if two buttons have been clicked and if they are a match""."
def check_match():
global buttons
clicked =[]
for b in buttons. values():
if b.BUTTON_OB]['relief']== "sunken":
clicked.append (b)
if len(clicked)2 :
if clicked [0].BUTTON_OBJ ['bg']== clicked[1].BUTTON_OBJ ['bg '] :
# It's a match
clicked [0]. BUTTON_OBJ. configure(fg='black', bg='black', relief='raised')
clicked [1].BUTTON_OBJ. configure(fg='black', bg='black', relief='raised ')
# black
else:
clicked [0]. BUTTON_OBJ. configure (fg='SystemButtonFace', bg='SystemButtonFace', relief='raised ')
clicked [1].BUTTON_OB]. configure (fg='SystemButtonFace', bg='SystemButtonFace', relief=' raised')
If a button is pushed, draw the correct colors"'."
def button_pushed(pushed_id):
global buttons
buttons [pushed_id].BUTTON_OBJ.configure(bg=buttons[pushed_id].COLOR, relief="sunken")
# Because time.sleep blocks execution, the color change for the second button clicked does not take effect until
# the function returns. So we need to use the 'after()' method
# Parameters:
# parent: is the object of the widget or main window whichever is using this function.
# ms: is the time in milliseconds.
# function: which shall be called.
# *args: other options.
buttons [pushed_id].BUTTON_OBJ.after(1500, check_match)
def close_options(top):
top.destroy()H
 import time from tkinter import * from random import randint class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!