Я скопировал код из предыдущего вопроса и попытался изменить его для работы с фреймами и менеджером сетки, но я не могу заставить его работать. Я думаю, что проблема может быть в функции create_cbuts и ссылке на frame1. Любая помощь будет оценена!
from tkinter import * # Python interface to the Tk GUI toolkit
from tkinter import ttk # Tk themed widget set
from tkinter import messagebox
def donothing():
return
def create_cbuts():
for index, item in enumerate(cbuts_text):
cbuts.append(Checkbutton(frame1, text = item))
cbuts[index].grid
def select_all():
for i in cbuts:
i.select()
def deselect_all():
for i in cbuts:
i.deselect()
def process_checkbox():
if (check_an.get() == 1):
print('Ancestry button checked')
if (check_ft.get() == 1):
print('FTDNA button checked')
if (check_gm.get() == 1):
print('GEDmatch button checked')
if (check_mh.get() == 1):
print('MyHeritage button checked')
if (check_me.get() == 1):
print('23&Me button checked')
root = Tk()
win2 = Toplevel(root)
win2.geometry('500x150') # Width x Height
win2.resizable(0, 0) # prevent window resizing
win2.title('Process DNA Match Files')
frame1 = Frame(win2)
frame2 = Frame(win2)
Label(frame1, text="Which files should be processed?").grid(row=0, column=0, sticky=W)
check_an = IntVar()
Checkbutton(frame1, text="Ancestry", variable=check_an).grid(row=1,column=0, sticky=W)
check_ft = IntVar()
Checkbutton(frame1, text="FTDNA", variable=check_ft).grid(row=2, column=0, sticky=W)
check_gm = IntVar()
Checkbutton(frame1, text="GEDmatch", variable=check_gm).grid(row=3, column=0, sticky=W)
check_mh = IntVar()
Checkbutton(frame1, text="MyHeritage", variable=check_mh).grid(row=1, column=1, sticky=W)
check_me = IntVar()
Checkbutton(frame1, text="23 and Me", variable=check_me).grid(row=2, column=1, sticky=W)
frame1.pack()
select_button = ttk.Button(frame2, text='Select All', width=15, command=select_all)
select_button.pack(side = LEFT, padx=5, pady=5)
select_button = ttk.Button(frame2, text='Deselect All', width=15, command=deselect_all)
select_button.pack(side = LEFT, padx=5, pady=5)
cancel_button =ttk.Button(frame2, text='Cancel', width=15, command=win2.destroy)
cancel_button.pack(side = LEFT, padx=5, pady=5)
ok_button =ttk.Button(frame2, text='OK', width=15, command=process_checkbox)
ok_button.pack(side = LEFT, padx=5, pady=5)
frame2.pack()
cbuts_text = ['Ancestry','FTDNA','GEDmatch','MyHeritage', '23 and Me']
cbuts = []
create_cbuts()
root.mainloop()
'''''