question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ScrolledFrame Behavior

See original GitHub issue

Is this a bug or expected behavior?

This code generates this layout:

import ttkbootstrap as ttk
from ttkbootstrap.constants import *
from ttkbootstrap.scrolled import ScrolledFrame

class MainFrame(ttk.Window):
    def __init__(self):
        ttk.Window.__init__(self)

        self.geometry('500x300')
        self.title('Tkinter')
        
        self.set_notebook()
        self.set_tab0()
        return

    def set_notebook(self):
        self.nb = ttk.Notebook(self)
        self.nb.place(relx=0, rely=0, relwidth=1, relheight=1)
        return

    def set_tab0(self):
        #self.frm = ScrolledFrame(self, autohide=True)
        self.frm = ttk.Frame(self)
        self.frm.place(relx=0, rely=0, relwidth=1, relheight=1)

        ##Top
        self.frm_top = ttk.Frame(self.frm)
        self.frm_top.pack(fill=BOTH, expand=1)

        ttk.Label(self.frm_top, text='frame 1: top place (10, 25)').place(x=10, y=25)
        
        ttk.Label(self.frm_top, text='frame 1: top pack').pack()

        #middle
        self.frm_middle = ttk.Frame(self.frm)
        self.frm_middle.pack(fill=BOTH, expand=1)

        ttk.Label(self.frm_middle, text='frame 2: middle - pack').pack()

        ttk.Label(self.frm_middle, text='frame 2: middle - place (10, 25)').place(x=10, y=25)

        #Bottom
        self.frm_bottom = ttk.Frame(self.frm)
        self.frm_bottom.pack(side=BOTTOM, fill=X)
        ttk.Label(self.frm_bottom, text='frame 3: bottom - pack').pack()

        #self.nb.add(self.frm.container, text='Test')
        self.nb.add(self.frm, text='Test')
        return

if __name__== '__main__':
    app = MainFrame()
    app.mainloop()
nromal

Scrolled:

If I replace the frame (self.frm) with a ScrolledFrame, see how the layout changes: the widget with .place was not displayed and the frame side=bottom does not obey the bottom position:

scrolled
import ttkbootstrap as ttk
from ttkbootstrap.constants import *
from ttkbootstrap.scrolled import ScrolledFrame

class MainFrame(ttk.Window):
    def __init__(self):
        ttk.Window.__init__(self)

        self.geometry('500x300')
        self.title('Tkinter')
        
        self.set_notebook()
        self.set_tab0()
        return

    def set_notebook(self):
        self.nb = ttk.Notebook(self)
        self.nb.place(relx=0, rely=0, relwidth=1, relheight=1)
        return

    def set_tab0(self):
        self.frm = ScrolledFrame(self, autohide=True)
        #self.frm = ttk.Frame(self)
        self.frm.place(relx=0, rely=0, relwidth=1, relheight=1)

        ##Top
        self.frm_top = ttk.Frame(self.frm)
        self.frm_top.pack(fill=BOTH, expand=1)

        ttk.Label(self.frm_top, text='frame 1: top place (10, 25)').place(x=10, y=25)
        
        ttk.Label(self.frm_top, text='frame 1: top pack').pack()

        #middle
        self.frm_middle = ttk.Frame(self.frm)
        self.frm_middle.pack(fill=BOTH, expand=1)

        ttk.Label(self.frm_middle, text='frame 2: middle - pack').pack()

        ttk.Label(self.frm_middle, text='frame 2: middle - place (10, 25)').place(x=10, y=25)

        #Bottom
        self.frm_bottom = ttk.Frame(self.frm)
        self.frm_bottom.pack(side=BOTTOM, fill=X)
        ttk.Label(self.frm_bottom, text='frame 3: bottom - pack').pack()

        self.nb.add(self.frm.container, text='Test')
        #self.nb.add(self.frm, text='Test')
        return

if __name__== '__main__':
    app = MainFrame()
    app.mainloop()

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
israel-dryercommented, Feb 8, 2022

@antrrax, the scrolled frame has a default width and height like the Canvas widget, however, you can override with pack, place, grid, just as with any other widget.

I’ve added a new parameter called scrollheight which sets the height of the content frame manually in the case that you are using a relative positioning such as in the example above.

self.frm = ScrolledFrame(self, autohide=True, scrollheight=300)
1reaction
antrraxcommented, Jan 17, 2022

I tested it with the same code as in the first post. At first the problem was solved. Thanks for the quick resolution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

scrolledframe - Create and manipulate scrolled frame widgets
Option and the args determine the exact behavior of the command. The following commands are possible for scrolledframe widgets: ...
Read more >
scrolledframeSection iwid
scrolledframe - Create and manipulate scrolled frame widgets ... Option and the args determine the exact behavior of the command. The following commands...
Read more >
man page(1) - ESO.org
Option and the args determine the exact behavior of the command. The following commands are possible for scrolledframe widgets: Associated Methods.
Read more >
ttkwidgets/scrolledframe.py at master - frames - GitHub
A frame that sports a vertically oriented scrollbar for scrolling. :ivar interior: :class:`ttk.Frame` in which to put the widgets to be ...
Read more >
scrolledframe.n.html - Apple Open Source
<TITLE>scrolledframe - Create and manipulate scrolled frame ... </pre> <I>Option</I> and the <I>arg</I>s determine the exact behavior of the command.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found