Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_chgbtncolorbind.py
- 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(event): ### (5)
- myParent.destroy() ### (6)
- quit()
- button1 = Button(myContainer1)
- button1.configure(text=" Change Color ", background="green")
- button1.pack(side=LEFT)
- button1.bind("<Button-1>", button1Click) ### (1)
- button2 = Button(myContainer1)
- button2.configure(text=" Exit ", background="red")
- button2.pack(side=RIGHT)
- button2.bind("<Button-1>", button2Click) ### (2)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement