Advertisement
here2share

# Tk_config_widgets.py

Jun 16th, 2015
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. # Tk_config_widgets.py
  2.  
  3. import Tkinter
  4. root = Tkinter.Tk()
  5.  
  6. msg1 = "Hide Label"
  7. msg2 = "Show Label"
  8.  
  9. button = Tkinter.Button(root, text=msg1)
  10. button.pack()
  11.  
  12. label = Tkinter.Label(root, text=">>> Label <<<")
  13.  
  14. def switch():
  15.     global sw
  16.     sw=(1,0)[sw]
  17.     print sw
  18.     if sw: label.pack(); msg = msg1
  19.     else: label.forget(); msg = msg2
  20.     button.config(text=msg)
  21.     button.pack()
  22. sw = 1
  23. label.pack()
  24.  
  25. button.config(command=switch)
  26. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement