I'm trying to create 3 sets of checkbox lists of varying lengths and then display them in three columns on a page within a tkinter GUI. List 1 will be a Integer based list, 2 & 3 are Strings. The variables for the names of these lists are defined earlier in the code before the GUI starts. N_index = [1, 2, 3]
T_index = [T1, T2, T3]
P_index = [P1, P2, P3]
The lengths of the lists will change each time the code is run so I have used this:
N_leng = range(1, int(len(N_index)+1))
T_leng = range(1, int(len(T_index)+1))
P_leng = range(1, int(len(P_index)+1))
The code I have partially used to create my GUI is taken from here Switch between two frames in tkinter (Thank-you)
I'm trying to put these lists into Page One.
class PageOne(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
f = tk.Frame(self)
f.pack(side="left")
label = ttk.Label(f, text="Page One", font=LARGE_FONT)
label.pack(pady=10, padx=10)
I then have the 3 sets of checkboxes. When I run the code it runs and never finishes. However it doesn't throw up an error even in debugging mode. Can someone spot my mistake?
def ckbox_params():
for i, j in zip(N_index, N_leng):
ivar = tk.IntVar()
N_selection1 = tk.Checkbutton(f, text="%d" % i, variable=ivar, onvalue=i, offvalue="")
N_selection1.grid(sticky="nw", pady=4)
for i, k in zip(T_index, T_leng):
svar = tk.StringVar()
T_selection1 = tk.Checkbutton(f, text="%s" % i, variable=svar, onvalue=i, offvalue="")
T_selection1.grid(sticky="nw", pady=4)
for i, l in zip(P_index, P_leng):
svar = tk.StringVar()
P_selection1 = tk.Checkbutton(f, text="%s" % i, variable=svar, onvalue=i, offvalue="")
P_selection1.grid(sticky="nw", pady=4)
ckbox_params()`
Any suggestions, ideas or solutions would be helpful as to what I've done wrong.
Thank you
Aucun commentaire:
Enregistrer un commentaire