Advertisement
here2share

# Tk_radio_btn_demo.py

Jul 28th, 2016
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. # Tk_radio_btn_demo.py
  2.  
  3. from Tkinter import *
  4.  
  5. cb_strings = ['item 1', 'item 2', 'item 3', 'item 4']
  6.  
  7. def sel():
  8.    print "You selected the option " + str(var.get())
  9.  
  10. root = Tk()
  11. var = StringVar()
  12. var.set(cb_strings[0])
  13.  
  14. for item in cb_strings:
  15.     button = Radiobutton(root, text=item, variable=var, value=item, command=sel)
  16.     button.pack(anchor=W)
  17.  
  18. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement