我正在使用tkinter模块制作todo应用程序。我已经制作了应用程序,但是我想在复选框部分添加滚动条。我该怎么办?
name=StringVar()
cost_var=StringVar()
check_box_list = []
def generate():
k=name.get()
if k!='':
f = Frame(window,bg='#dee2de')
Checkbutton(f,bg='#dee2de', var=StringVar(), text=k).pack(side='left',fill=X)
Button(f, text='✕', command=f.destroy,bg='#dd2f2c').pack(side='right')
check_box_list.append(f) # add Frame
f.pack(fill=X)
name.set('')
def clear():
for i in check_box_list:
if i.winfo_exists(): # Checks if the widget exists or not
i.destroy()
name.set('')
lbl=Label(window,text="Enter your Task").pack()
# To get the entry
ent=Entry(window,width=10,bg='#b8b8bc',textvariable=name)
ent.pack(fill=X)
# Submit Button
btn1=Button(window,text="Submit", fg='white',bg='blue',command= generate)
btn1.pack(fill=X)
# Clear Button
btn2=Button(window,text="Clear", fg='white',bg='#f44e42',command= clear)
btn2.pack(fill=X)
lbl3=Label(window,text=today,bg='#d5edc7').pack(fill=X)
lbl3=Label(window,text="Today's Task:",bg='#414240',fg='white').pack(fill=X)
我想在复选框列表中添加一个滚动条,以便当This is an image of todo app窗口不适合时可以滚动浏览。