Advertisement
here2share

# Tk_chgbtncolorbind.py

Jan 3rd, 2016
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. # Tk_chgbtncolorbind.py
  2.  
  3. from Tkinter import *
  4.  
  5. root = Tk()
  6. myParent = root  ### (7)
  7. myContainer1 = Frame(root)
  8. myContainer1.pack()
  9.  
  10. def button1Click(event):    ### (3)
  11.     if button1["background"] == "green": ### (4)
  12.         button1["background"] = "yellow"
  13.     else:
  14.         button1["background"] = "green"
  15.  
  16. def button2Click(event):  ### (5)
  17.     myParent.destroy()     ### (6)
  18.     quit()
  19.  
  20. button1 = Button(myContainer1)
  21. button1.configure(text=" Change Color ", background="green")
  22. button1.pack(side=LEFT)
  23. button1.bind("<Button-1>", button1Click) ### (1)
  24.  
  25. button2 = Button(myContainer1)
  26. button2.configure(text=" Exit ", background="red")  
  27. button2.pack(side=RIGHT)
  28. button2.bind("<Button-1>", button2Click) ### (2)
  29.  
  30. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement