Advertisement
here2share

# Tk_config_widgets_2_retain_size.py

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