Tkinter Checkbuttons Not Changing The Variable Value
My skills with Tkinter are improving day by day, I cannot believe how far I am compared to 2 weeks ago. Now my problem is that I cannot make the Checkbuttons work. For some reason
Solution 1:
You need to create child window by creating instances of Toplevel:
change
window= Tk()
towindow= Toplevel()
need to use Toplevel() for a window that opens on another window.
code:
from tkinter import *
def runp():
def cb(vari):
print ("variable is {0}".format(vari.get()))
window = Toplevel() # <-------------------
window.title("Please choose the parameters")
window.geometry('500x350')
labelSelect=Label(window, text="Which Rdata file would you like to load? (from output directory)")
labelSelect.grid(column=0, row=11)
FastaC=BooleanVar()
RwMatrix=BooleanVar()
RwSum=BooleanVar()
RwInfo=BooleanVar()
FastaCRadio=Checkbutton(window, text="FastaClean.Rdata", variable=FastaC, command=lambda: cb(FastaC))
FastaCRadio.grid(column=1, row=11)
RwSumRadio=Checkbutton(window, text="RwMatrix.Rdata", variable=RwMatrix, command=lambda: cb(RwMatrix))
RwSumRadio.grid(column=1, row=12)
RwSumRadio=Checkbutton(window, text="RwSum.Rdata", variable=RwSum, command=lambda: cb(RwSum))
RwSumRadio.grid(column=1, row=13)
RwInfoRadio=Checkbutton(window, text="RwInfo.Rdata", variable=RwInfo,command=lambda:cb(RwInfo))
RwInfoRadio.grid(column=1, row=14)
window.mainloop()
master=Tk()
Button(master, text="RW", command=runp).pack()
master.mainloop()
Post a Comment for "Tkinter Checkbuttons Not Changing The Variable Value"