将垂直和水平条设置为 canvas
setting vertical and horizontal bars to canvas
谁能帮我解决这个问题,似乎无法让滚动条工作:(
canvas = Canvas(tab0, bg='red')
frmbtnspecs = ttk.Frame(canvas)
frmbtnspecs.pack(side="top")
lbl = Label(frmbtnspecs, width=8, text="Model:", justify=RIGHT, anchor="e").grid(row=0, column=4, sticky=W, pady=2)
inp_cond_model = Text(frmbtnspecs, height=1, width=35, relief=GROOVE, borderwidth=2)
inp_cond_model.grid(row=0, column=5, sticky=NW, pady=2)
lbl = Label(frmbtnspecs, width=16, text="Version:", justify=RIGHT, anchor="e").grid(row=0, column=6,
sticky=W, pady=2)
inp_cond_firmware = Text(frmbtnspecs, height=1, width=35, relief=GROOVE, borderwidth=2)
inp_cond_firmware.grid(row=0, column=7, sticky=NW, pady=2)
frmbtn = ttk.Frame(canvas)
frmbtn.pack(side="top", expand=1, fill="both")
coll = int(0)
specvar = int(1)
ttk.Button(frmbtn, width="5", text="OK", image=photoOK).grid(column=coll, row=3, padx=1, pady=1)
ttk.Button(frmbtn, width="5", text="Not Ok", image=photoNot).grid(column=coll, row=4, padx=1, pady=1)
lblspec = Label(frmbtn, text=y_respexpt, justify='left', anchor=N)
lblspec.grid(column=coll, row=5, rowspan=55, sticky=N, padx=20, pady=20)
vertibar = Scrollbar(tab0, orient=VERTICAL)
vertibar.pack(side=RIGHT, fill=Y)
vertibar.config(command=canvas.yview)
horibar = Scrollbar(tab0, orient=HORIZONTAL)
horibar.pack(side=BOTTOM, fill=X)
horibar.config(command=canvas.xview)
canvas.pack(expand=True, side=LEFT, fill=BOTH)
canvas.config(xscrollcommand=horibar.set, yscrollcommand=vertibar.set)
出现滚动条的地方但什么也没做enter image description here
container = ttk.Frame(root)
canvas = tk.Canvas(container)
scrollbar_x = ttk.Scrollbar(container, orient="horizontal", command=canvas.xview)
scrollbar_y = ttk.Scrollbar(container, orient="vertical", command=canvas.yview)
scrollable_frame = ttk.Frame(canvas)
..您的代码(在 scrollable_frame 内)
container.pack(expand=1, fill="both")
scrollbar_x.pack(side="bottom", fill="x")
scrollbar_y.pack(side="right", fill="y")
canvas.pack(side="bottom", fill="both", expand=True)
谁能帮我解决这个问题,似乎无法让滚动条工作:(
canvas = Canvas(tab0, bg='red')
frmbtnspecs = ttk.Frame(canvas)
frmbtnspecs.pack(side="top")
lbl = Label(frmbtnspecs, width=8, text="Model:", justify=RIGHT, anchor="e").grid(row=0, column=4, sticky=W, pady=2)
inp_cond_model = Text(frmbtnspecs, height=1, width=35, relief=GROOVE, borderwidth=2)
inp_cond_model.grid(row=0, column=5, sticky=NW, pady=2)
lbl = Label(frmbtnspecs, width=16, text="Version:", justify=RIGHT, anchor="e").grid(row=0, column=6,
sticky=W, pady=2)
inp_cond_firmware = Text(frmbtnspecs, height=1, width=35, relief=GROOVE, borderwidth=2)
inp_cond_firmware.grid(row=0, column=7, sticky=NW, pady=2)
frmbtn = ttk.Frame(canvas)
frmbtn.pack(side="top", expand=1, fill="both")
coll = int(0)
specvar = int(1)
ttk.Button(frmbtn, width="5", text="OK", image=photoOK).grid(column=coll, row=3, padx=1, pady=1)
ttk.Button(frmbtn, width="5", text="Not Ok", image=photoNot).grid(column=coll, row=4, padx=1, pady=1)
lblspec = Label(frmbtn, text=y_respexpt, justify='left', anchor=N)
lblspec.grid(column=coll, row=5, rowspan=55, sticky=N, padx=20, pady=20)
vertibar = Scrollbar(tab0, orient=VERTICAL)
vertibar.pack(side=RIGHT, fill=Y)
vertibar.config(command=canvas.yview)
horibar = Scrollbar(tab0, orient=HORIZONTAL)
horibar.pack(side=BOTTOM, fill=X)
horibar.config(command=canvas.xview)
canvas.pack(expand=True, side=LEFT, fill=BOTH)
canvas.config(xscrollcommand=horibar.set, yscrollcommand=vertibar.set)
出现滚动条的地方但什么也没做enter image description here
container = ttk.Frame(root)
canvas = tk.Canvas(container)
scrollbar_x = ttk.Scrollbar(container, orient="horizontal", command=canvas.xview)
scrollbar_y = ttk.Scrollbar(container, orient="vertical", command=canvas.yview)
scrollable_frame = ttk.Frame(canvas)
..您的代码(在 scrollable_frame 内)
container.pack(expand=1, fill="both")
scrollbar_x.pack(side="bottom", fill="x")
scrollbar_y.pack(side="right", fill="y")
canvas.pack(side="bottom", fill="both", expand=True)