Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_chgbtncolorbind2.py -- proper exit proceedure added
- from Tkinter import *
- root = Tk()
- myParent = root ### (7)
- myContainer1 = Frame(root)
- myContainer1.pack()
- def button1Click(event): ### (3)
- if button1["background"] == "green": ### (4)
- button1["background"] = "yellow"
- else:
- button1["background"] = "green"
- def button2Click(): ### (5)
- myParent.destroy() ### (6)
- button1 = Button(myContainer1)
- button1.configure(text=" Change Color ", background="green")
- button1.pack(side=LEFT)
- button1.bind("<Button-1>", button1Click) ### (1)
- button2 = Button(myContainer1, command=button2Click)
- button2.configure(text=" Exit ", background="red")
- button2.pack(side=RIGHT)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement