带有水平和垂直滚动条的python Tkinter框架

时间:2019-01-04 04:15:33

标签: python python-3.x tkinter

我正在尝试在笔记本中创建一个框架,该框架将使用https://lucasg.github.io/2015/07/21/How-to-make-a-proper-double-scrollbar-frame-in-Tkinter/中的类代码进行滚动

但是,无论出于什么原因,当我使窗口小于内容区域时(ScheduleMatrix是一个ttk.Frame,其中包含一堆小部件),滚动条会调整大小,但保持不活动和不可用。我想念什么?如果有所不同,则使用网格几何管理器排列添加到ScheduleMatrix框架的小部件。

class BVSGUI(ttk.Frame):
    def __init__(self, master):
        ttk.Frame.__init__(self, master)
        nb = ttk.Notebook(self)
        nb.pack(expand=True, fill="both")
        nb.enable_traversal()

        p1 = ttk.Frame(nb)
        p1.pack(expand=True, fill="both")
        nb.add(p1, text='First Tab', underline=0)
        ds1 = DoubleScrollbarFrame(p1)
        ds1.pack(expand=True, fill="both")
        m1 = ScheduleMatrix(ds1.canvas)
        m1.pack(expand=True, fill="both")

        p23 = ttk.Frame(nb)
        p23.pack(expand=True, fill="both")
        nb.add(p23, text='Tab 23', underline=0)
        ds23 = DoubleScrollbarFrame(p23)
        ds23.pack(expand=True, fill="both")
        m23 = ScheduleMatrix(ds23.canvas)
        m23.pack(expand=True, fill="both")

1 个答案:

答案 0 :(得分:0)

我为您制作了一个框架,here可用。像普通框架一样使用它,而不像上面那样。像这样:

p1 = DoubleScrolledFrame(nb)
nb.add(p1, text='First Tab', underline=0)
m1 = ScheduleMatrix(p1)
m1.pack(expand=True, fill="both")
相关问题