May-26-2019, 05:51 AM
I have checkboxes in a secondary tkinter window (not root) that only return an IntVar of 0 even when selected. This is not a problem in the main window.
I have the code working in the main root window and when selected, the checkboxes return 1 and not 0, however when using the exact same code in a separate tkinter window it returns only 0's. I have added window2.mainloop() at the end which did nothing.
I have the code working in the main root window and when selected, the checkboxes return 1 and not 0, however when using the exact same code in a separate tkinter window it returns only 0's. I have added window2.mainloop() at the end which did nothing.
button_list = [] #create list to hold checkbox values def done_press(): #what to do when done button pressed for x in range(len(data)): print(button_list[x].get()) play = Tk() #second window called play row=[1,2,3,4,5,6,7,8,9] Label(play, text='Whats on').grid(row=0, column=0, padx=30, pady=20, columnspan=3) for box in range(len(data)): #create checkboxes button_list.append(IntVar()) #append checkbox list for each selected button = Checkbutton(play, text=data[box], variable=button_list,) button.grid(column=0,row=row[box], pady=5, padx=30) done = Button(play, text='Done', command=done_press) done.grid(column=0,row=11, columnspan=2) play.mainloop()any help would be appreciated, thanks.