GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||
GeezerVison is showing docs.wxpython.org — Scrolled Windows Overview — wxPython 4.3.2 Docs
|
orientation |
Which scrollbar: |
position |
The position of the scrollbar in scroll units. |
visible |
The size of the visible portion of the scrollbar, in scroll units. |
range |
The maximum position of the scrollbar. |
refresh |
Whether the scrollbar should be repainted. |
orientation determines whether we’re talking about the built-in horizontal or vertical scrollbar.
position is simply the position of the ‘thumb’ (the bit you drag to scroll around). It is given in scroll units, and so is relative to the total range of the scrollbar.
visible gives the number of scroll units that represents the portion of the window currently visible. Normally, a scrollbar is capable of indicating this visually by showing a different length of thumb.
range is the maximum value of the scrollbar, where zero is the start position. You choose the units that suit you, so if you wanted to display text that has 100 lines, you would set this to 100. Note that this doesn’t have to correspond to the number of pixels scrolled - it is up to you how you actually show the contents of the window.
refresh just indicates whether the scrollbar should be repainted immediately or not.
Let’s say you wish to display 50 lines of text, using the same font. The window is sized so that you can only see 16 lines at a time. You would use:
SetScrollbar(wx.VERTICAL, 0, 16, 50)
Note
Note that with the window at this size, the thumb position can never go above 50 minus 16, or 34. You can determine how many lines are currently visible by dividing the current view size by the character height in pixels.
When defining your own scrollbar behaviour, you will always need to recalculate the scrollbar settings when the window size changes. You could therefore put your scrollbar calculations and SetScrollbar call into a function named AdjustScrollbars, which can be called initially and also from your wx.SizeEvent handler function.