Tkinter助手生成的GUI怎么才能绑定滚动条

我不太懂这种初始化GUI的方式, 尝试过在容器内创建滚动条 但是绑定的时候会因为对象属性问题报错
生成的源代码如下


from tkinter import *
from tkinter.ttk import *


class WinGUI(Tk):
    def __init__(self):
        super().__init__()
        self.__win()
        self.tk_tabs_ldwd7cby = Frame_ldwd7cby(self)

    def __win(self):
        self.title("Tkinter布局助手")
        # 设置窗口大小、居中
        width = 600
        height = 500
        screenwidth = self.winfo_screenwidth()
        screenheight = self.winfo_screenheight()
        geometry = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
        self.geometry(geometry)
        self.resizable(width=False, height=False)


class Frame_ldwd7cby(Notebook):
    def __init__(self, parent):
        super().__init__(parent)
        self.__frame()

    def __frame(self):
        self.tk_tabs_ldwd7cby_0 = Frame_ldwd7cby_0(self)
        self.add(self.tk_tabs_ldwd7cby_0, text="选项卡1")

        self.tk_tabs_ldwd7cby_1 = Frame_ldwd7cby_1(self)
        self.add(self.tk_tabs_ldwd7cby_1, text="选项卡2")

        self.place(x=0, y=0, width=599, height=490)


class Frame_ldwd7cby_0(Frame):
    def __init__(self, parent):
        super().__init__(parent)
        self.__frame()
        self.tk_list_box_ldwd7ol0 = self.__tk_list_box()

    def __frame(self):
        self.place(x=0, y=0, width=599, height=490)

    def __tk_list_box(self):
        lb = Listbox(self)
        lb.insert(END, "列表框")
        lb.insert(END, "Python")
        lb.insert(END, "Tkinter Helper")
        lb.place(x=30, y=20, width=355, height=326)

        return lb




class Frame_ldwd7cby_1(Frame):
    def __init__(self, parent):
        super().__init__(parent)
        self.__frame()

    def __frame(self):
        self.place(x=0, y=0, width=599, height=490)


class Win(WinGUI):
    def __init__(self):
        super().__init__()
        self.__event_bind()

    def __event_bind(self):
        pass


if __name__ == "__main__":
    win = Win()
    win.mainloop()


下面是我的插入方法 ,提示 'Frame_ldwd7cby_0' object has no attribute 'scroll_y1'


from tkinter import *
from tkinter.ttk import *


class WinGUI(Tk):
    def __init__(self):
        super().__init__()
        self.__win()
        self.tk_tabs_ldwd7cby = Frame_ldwd7cby(self)

    def __win(self):
        self.title("Tkinter布局助手")
        # 设置窗口大小、居中
        width = 600
        height = 500
        screenwidth = self.winfo_screenwidth()
        screenheight = self.winfo_screenheight()
        geometry = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
        self.geometry(geometry)
        self.resizable(width=False, height=False)


class Frame_ldwd7cby(Notebook):
    def __init__(self, parent):
        super().__init__(parent)
        self.__frame()

    def __frame(self):
        self.tk_tabs_ldwd7cby_0 = Frame_ldwd7cby_0(self)
        self.add(self.tk_tabs_ldwd7cby_0, text="选项卡1")

        self.tk_tabs_ldwd7cby_1 = Frame_ldwd7cby_1(self)
        self.add(self.tk_tabs_ldwd7cby_1, text="选项卡2")

        self.place(x=0, y=0, width=599, height=490)


class Frame_ldwd7cby_0(Frame):
    def __init__(self, parent):
        super().__init__(parent)
        self.__frame()
        self.tk_list_box_l = self.__tk_list_box()
        self.scroll_y1 = self.__scrollbar_y()

    def __frame(self):
        self.place(x=0, y=0, width=599, height=490)

    def __tk_list_box(self):
        lb = Listbox(self,yscrollcommand=self.scroll_y1.set)
        lb.insert(END, "列表框")
        lb.insert(END, "Python")
        lb.insert(END, "Tkinter Helper")
        lb.place(x=30, y=20, width=355, height=326)
        return lb

    def __scrollbar_y(self):
        scly = Scrollbar(self)
        scly.place(x=370, y=20 , width=20, height=326)
        scly.config(command= self.tk_list_box_l.yview)

        return scly



class Frame_ldwd7cby_1(Frame):
    def __init__(self, parent):
        super().__init__(parent)
        self.__frame()

    def __frame(self):
        self.place(x=0, y=0, width=599, height=490)


class Win(WinGUI):
    def __init__(self):
        super().__init__()
        self.__event_bind()

    def __event_bind(self):
        pass


if __name__ == "__main__":
    win = Win()
    win.mainloop()


请问怎么样才能正确绑定滚动条

我给一个简单的示例,你一看就知道了:

import tkinter as tk

root = tk.Tk()

listbox = tk.Listbox(root)
scrollbar = tk.Scrollbar(root, orient="vertical", command=listbox.yview)
listbox.configure(yscrollcommand=scrollbar.set)

listbox.pack(side="left", fill="both", expand=True)
scrollbar.pack(side="right", fill="y")

for i in range(1000):
    listbox.insert("end", str(i))

root.mainloop()

如果是水平滚动条,就设置xscrollcommand属性

https://blog.csdn.net/sljsxy/article/details/128238603
参考一下这篇文章吧

首先,您必须将connect()函数的参数设置为要连接的滚动条和GUI部件之间的关联;然后,使用configure()函数来指定滚动条被触发响应的事件,例如每次滚动条被移动多少;最后,您可以在GUI部件上添加滚动条,并且通过configure()函数来设置滚动条的位置和大小。

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^