Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 在Tkinter中将滚动条添加到列表框_Python 3.x_Tkinter - Fatal编程技术网

Python 3.x 在Tkinter中将滚动条添加到列表框

Python 3.x 在Tkinter中将滚动条添加到列表框,python-3.x,tkinter,Python 3.x,Tkinter,我在这件事上绕圈子。我检查了十几篇帖子,没有发现我做错了什么。代码如下: from tkinter import * class Frame1(Frame): def __init__(self, master): #super().__init__() self.lblTitle = Label(master, text="Ticket List") self.lblTitle.grid(row=0, column=0)

我在这件事上绕圈子。我检查了十几篇帖子,没有发现我做错了什么。代码如下:

from tkinter import *
class Frame1(Frame):
    def __init__(self, master):
        #super().__init__()

        self.lblTitle = Label(master, text="Ticket List")
        self.lblTitle.grid(row=0, column=0)
        self.listTickets = Listbox(master, width=20, height=20, font=("Arial", 11))
        self.listTickets.grid(row=1, column=0)
        self.scrollbar = Scrollbar(master, orient=VERTICAL)
        self.scrollbar.grid(row=1, column=1)
        self.listTickets.config(yscrollcommand=self.scrollbar.set)
        self.scrollbar.config(command=self.listTickets.yview)

        for i in range(1000):
            self.listTickets.insert(END, str(i))


window = Tk()
window.title("Ticket System")
frame = Frame1(window)

window.mainloop()
我哪里出错了?这只会创建一个微小的上/下箭头,而不是真正的滚动条

您必须在scrollbar的网格函数中使用sticky参数来扩展scrollbar的南北方向。你可以进一步了解它

您必须在scrollbar的网格函数中使用sticky参数来扩展scrollbar的南北方向。你可以进一步了解它

self.scrollbar.grid(row=1, column=1, sticky="ns")