wx.lib.scrolledpanel.ScrolledPanel¶
ScrolledPanel
fills a “hole” in the implementation of
ScrolledWindow
, providing automatic scrollbar and scrolling
behavior and the tab traversal management that ScrolledWindow
lacks.
Class Hierarchy¶
Known Superclasses¶
Methods Summary¶
Default class constructor. |
|
Same as child.GetRect() except the position returned is relative |
|
If the child window that gets the focus is not fully visible, |
|
Scroll the panel so that the specified child window is in view. |
|
This function sets up the event handling necessary to handle |
Class API¶
- class ScrolledPanel(wx.ScrolledWindow)¶
ScrolledPanel
fills a “hole” in the implementation ofScrolledWindow
, providing automatic scrollbar and scrolling behavior and the tab traversal management thatScrolledWindow
lacks.
Methods¶
- __init__(self, parent, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TAB_TRAVERSAL, name='scrolledpanel')¶
Default class constructor.
- Parameters:
parent (wx.Window) – parent window. Must not be
None
;id (integer) – window identifier. A value of -1 indicates a default value;
pos (tuple or
wx.Point
) – the control position. A value of (-1, -1) indicates a default position, chosen by either the windowing system or wxPython, depending on platform;size (tuple or
wx.Size
) – the control size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxPython, depending on platform;style (integer) – the underlying
wx.ScrolledWindow
style;name (string) – the scrolled panel name.
- GetChildRectRelativeToSelf(self, child: wx.Window)¶
Same as child.GetRect() except the position returned is relative to this ScrolledPanel rather than the child’s parent.
Note
window.GetRect returns the size of a window, and its position relative to its parent. When calculating ScrollChildIntoView, the position relative to its parent is not relevant unless the parent is the ScrolledPanel itself.
- OnChildFocus(self, evt)¶
If the child window that gets the focus is not fully visible, this handler will try to scroll enough to see it.
- Parameters:
evt – a
ChildFocusEvent
event to be processed.
- ScrollChildIntoView(self, child)¶
Scroll the panel so that the specified child window is in view.
Note
This method looks redundant if evt.Skip() is called as well - the base
ScrolledWindow
widget now seems to be doing the same thing anyway.
- SetupScrolling(self, scroll_x=True, scroll_y=True, rate_x=20, rate_y=20, scrollToTop=True, scrollIntoView=True)¶
This function sets up the event handling necessary to handle scrolling properly. It should be called within the
__init__
function of any class that is derived fromScrolledPanel
, once the controls on the panel have been constructed and thus the size of the scrolling area can be determined.- Parameters:
scroll_x (bool) –
True
to allow horizontal scrolling,False
otherwise;scroll_y (bool) –
True
to allow vertical scrolling,False
otherwise;rate_x (int) – the horizontal scroll increment;
rate_y (int) – the vertical scroll increment;
scrollToTop (bool) –
True
to scroll all way to the top,False
otherwise;scrollIntoView (bool) –
True
to scroll a focused child into view,False
otherwise.