我现在的代码只会打印按钮,不会创建滚动条。我希望它打印按钮并允许我滚动它们。我能做的最好的事情是创建滚动条,但不让它附加到任何东西上?我是 python GUI 的新手,所以我对这些东西不太熟悉。这是我的代码:
def remove1():
newWindow1 = tk.Toplevel(root)
newWindow1.title("Remove Suppliers")
newWindow1.canvas = tk.Canvas()
newWindow1.canvas.pack()
sb = tk.Scrollbar(newWindow1.canvas)
sb.pack()
newWindow1.canvas.config(yscrollcommand=sb.set)
sb.config(command = newWindow1.canvas.yview)
newWindow1.canvas.configure(scrollregion=newWindow1.canvas.bbox("all"))
newWindow1.canvas.button = []
i = 0
for keys in supplier_dict:
newWindow1.canvas.button.append(tk.Button(newWindow1, text=keys,command = lambda i=i: self.open_this(i)))
newWindow1.canvas.button[i].pack(side = "top", fill = "both")
i+=1
z = 1
edit_suppliers(supplier_dict)