|
1 | | -# Scrollable Frame for Tkinter |
2 | | -A scrollable frame which just works:tm:! |
| 1 | +# Scrollable containers which *just work*:tm:! |
3 | 2 |
|
4 | 3 | If you have developed GUI applications, you probably know the pain of designing a clean front-end only to find that |
5 | | -your application window is too large for your client's screen. Making the content scrollable is not straightforward, at |
6 | | -least in Tkinter. Especially not after you have already written a lot of code to draw the content. |
| 4 | +your application window is too large for your client's screen. Making the content scrollable is not straightforward (at |
| 5 | +least in Tkinter). Especially not after you have already written a lot of code to draw the content. |
7 | 6 |
|
8 | | -You can use `ScrollableFrameTk` to reduce headaches. It automatically handles horizontal and vertical scrolling, and |
9 | | -doesn't break when the window is resized. If the window is wider than its contents, the latter will be horizontally |
10 | | -centred. Also, scrolling the mouse wheel vertically scrolls the window; if shift is held down, it horizontally scrolls |
11 | | -the window. Two-finger swipe gestures on the touchpad can also be used to scroll horizontally and vertically. |
| 7 | +You can use `ScrollableContainers` to reduce headaches. Run the following commands to install the package. |
12 | 8 |
|
13 | | -### TL;DR |
14 | | -Add widgets to the `frame` attribute of a `ScrollableFrameTk` object. |
15 | | -```python |
16 | | -import tkinter as tk |
17 | | - |
18 | | -from ScrollableContainers.Tk import ScrollableFrameTk |
19 | | - |
20 | | -root = tk.Tk() |
21 | | -scrollable_frame = ScrollableFrameTk(root) |
22 | | -for _ in range(100): |
23 | | - tk.Label(scrollable_frame.frame, text='Label ' * 30).pack() |
24 | | - |
25 | | -scrollable_frame.pack(expand=True, fill=tk.BOTH) |
26 | | -root.mainloop() |
| 9 | +```shell |
| 10 | +git clone https://github.com/tfpf/ScrollableContainers.git |
| 11 | +cd ScrollableContainers |
| 12 | +pip install . |
27 | 13 | ``` |
28 | 14 |
|
29 | | -See also [`examples.py`](examples.py) for more. |
| 15 | +## `ScrollableFrameTk` |
| 16 | +A full implementation of a scrollable frame in Tkinter. |
| 17 | +* Handles resize events correctly. |
| 18 | +* Horizontally centres the contents if the window is wider. |
| 19 | +* Supports scrolling with the mouse wheel and touchpad. |
| 20 | + * Scrolling the mouse or swiping vertically with two fingers on the touchpad triggers a vertical scroll. |
| 21 | + * Scrolling the mouse while holding down Shift or swiping horizontally with two fingers on the touchpad triggers a |
| 22 | + horizontal scroll. |
30 | 23 |
|
| 24 | +### Usage |
| 25 | +Add widgets to the `frame` attribute of a `ScrollableFrameTk` object. See |
| 26 | +[`examples/examples_ScrollableFrameTk.py`](examples/examples_ScrollableFrameTk.py). |
| 27 | + |
| 28 | +### Notes |
31 | 29 | `'<Button-4>'`, `'<Button-5>'` and `'<MouseWheel>'` are bound to all widgets using `bind_all` to handle mouse wheel |
32 | 30 | scroll events. Do not `unbind_all` (or `bind_all` another function to) these three sequences! |
| 31 | + |
| 32 | +## `ScrollablePanelWx` |
| 33 | +A thin wrapper around `wx.lib.scrolledpanel.ScrolledPanel`. |
| 34 | +* Does everything the aforementioned class does. |
| 35 | +* Horizontally centres the contents if the window is wider. |
| 36 | + |
| 37 | +### Usage |
| 38 | +Add widgets to the `panel` attribute of a `ScrollablePanelWx` object. See |
| 39 | +[`examples/examples_ScrollablePanelWx.py`](examples/examples_ScrollablePanelWx.py). |
0 commit comments