Advertisement
here2share

# Tk_Radiobutton2list.py

Jun 2nd, 2018
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. # Tk_Radiobutton2list.py
  2.  
  3. from Tkinter import *
  4.  
  5. features = ['a', 'b', 'c', 'd']
  6. master = Tk()
  7. row = 0
  8. mappe = {}
  9. v = {}
  10.  
  11. def saver(each):
  12.     print(each, v[each].get())
  13.     mappe[each] = v[each].get()
  14.     print mappe
  15.  
  16. MODES = [ ("String", "str"), ("Number","num")]
  17.  
  18. for each in features:
  19.  
  20.     if row >4 :
  21.         continue
  22.  
  23.     Label(master, text=each).grid(row=row, column=0)
  24.     v[each] = StringVar()
  25.     v[each].set("default")
  26.     col = 1
  27.  
  28.     for text, mode in MODES:
  29.         Radiobutton(master, text=text, variable=v[each],value = mode, command=lambda feature=each: saver(feature)).grid(row=row,column=col)
  30.         col+=1
  31.  
  32.     row += 1  
  33.  
  34. master.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement