ywlke
ywlke

Reputation: 23

python Tkinter frame with both horizontal and vertical scrollbars

I'm trying to create a Frame within a Notebook that will scroll using the class code from https://lucasg.github.io/2015/07/21/How-to-make-a-proper-double-scrollbar-frame-in-Tkinter/

However, for whatever reason, when I make the window smaller than the content area (ScheduleMatrix is a ttk.Frame that contains a bunch of widgets), the scrollbars resize but remain inactive and unusable. What am I missing? If it makes a difference, the widgets added to the ScheduleMatrix Frame are arranged using the grid geometry manager.

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")

Upvotes: 2

Views: 616

Answers (1)

Novel
Novel

Reputation: 13729

I made a Frame for you that does this, available here. Use it like a normal Frame, not like you did above. Like this:

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

Upvotes: 2

Related Questions