【发布时间】:2019-02-12 12:03:32
【问题描述】:
我正在尝试使用 tkinter 向我的画布添加滚动条,但我正在运行的代码没有创建可用的滚动条。错误是什么?
这是代码:
proofscreen.title("Proof")
proofscreen.geometry("800x800")
proofscreen.configure(background="white")
# add scrollbar
frame = Frame(proofscreen)
frame.grid()
canvas = Canvas(frame, bg="white")
vbar = Scrollbar(frame)
vbar.grid(row=0, column=1)
vbar.config(command=canvas.yview)
canvas.update()
canvas.config(yscrollcommand=vbar.set)
canvas.grid(row=0, column=0)
frame.grid_columnconfigure((0, 1), weight=1)
proofscreen.grid_columnconfigure((0), weight=1)
frame.grid_rowconfigure((0), weight=1)
proofscreen.grid_rowconfigure((0), weight=1)
Label(canvas, text="Proof", font=("Calibri", 16), bg="white", fg="black").pack(anchor=W)
Label(canvas, text="", bg="white", fg="black").pack(anchor=W)
Label(canvas, text="Deduction", font=("Calibri", 14), bg="white", fg="black").pack(anchor=W)
当画布中有很多标签时,我只需要滚动条能够垂直滚动
【问题讨论】: