Advertisement
here2share

# Tk_chgbtncolorbind2.py

Jan 3rd, 2016
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. # Tk_chgbtncolorbind2.py -- proper exit proceedure added
  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():  ### (5)
  17.     myParent.destroy()     ### (6)
  18.  
  19. button1 = Button(myContainer1)
  20. button1.configure(text=" Change Color ", background="green")
  21. button1.pack(side=LEFT)
  22. button1.bind("<Button-1>", button1Click) ### (1)
  23.  
  24. button2 = Button(myContainer1, command=button2Click)
  25. button2.configure(text=" Exit ", background="red")  
  26. button2.pack(side=RIGHT)
  27.  
  28. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement