May-26-2019, 09:52 AM
(May-26-2019, 09:37 AM)Yoriz Wrote: The code shown does not run, there is no tkinter import and data has not been defined.
Unable to compare if you are using the exact same code in main root window as secondary window as only one windows code is shown.
In the code shown when the Checkbutton's are created instead of each individual IntVar being passed as an argument to parameter variable, the whole data list is being passed.
Sorry, i tried to keep the snippet of code as short as possible so it was easier to understand, here is code that could be copy and pasted into IDLE:
from tkinter import * data = ['a','b','c','d','e','f','g','h','i'] 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()I now see that this doesnt even work when the window is the main window... do you know how i would make it so that each individual IntVar is passed as an argument to parameter variable?