python - Radiobuttons are modifying wrong values tkinter -


i working on script tkinter, weird happening.

i have 2 radiobuttons:

way=false radiobutton0=radiobutton(root,text="from",variable=way,value=false) radiobutton1=radiobutton(root,text="to",variable=way,value=true) radiobutton0.grid(column=0,row=2) radiobutton1.grid(column=1,row=2) 

and text entry field:

entryvalue=0 entryfield=entry(root,textvariable=entryvalue) entryfield.grid(column=0,row=4) 

when enter 0 in entry field, radiobutton0 automatically selected, when enter 1, radiobutton1 selected , other value, both selected... works vice versa: when select radiobutton0, entry field changes 0 , when select radiobutton1, entry field changes 1... also, entryvalue later seen 0. variable way should modified radio buttons...

why happening? doing shouldn't? , how fix it?

you can use command call method , set value. please refer attached code.

def sel():    selection = "you selected option " + str(var.get())    label.config(text = selection)   root = tk() frame = frame(root) frame.pack()  labelframe = labelframe(frame, text="this labelframe") labelframe.pack(fill="both", expand="yes")   var = intvar() r1 = radiobutton(labelframe, text="option 1", variable=var, value=1,                   command=sel) r1.pack( anchor = w )  r2 = radiobutton(labelframe, text="option 2", variable=var, value=2,                   command=sel) r2.pack( anchor = w )  r3 = radiobutton(labelframe, text="option 3", variable=var, value=3,                   command=sel) r3.pack( anchor = w)   label = label(labelframe) label.pack() 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -