Skip to content

Commit aeedd0f

Browse files
committed
Fixed wxPython example padding to resemble Tkinter's.
And updated the README to showcase `ScrollablePanelWx`.
1 parent 2baad68 commit aeedd0f

File tree

2 files changed

+31
-24
lines changed

2 files changed

+31
-24
lines changed

README.md

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,39 @@
1-
# Scrollable Frame for Tkinter
2-
A scrollable frame which just works:tm:!
1+
# Scrollable containers which *just work*:tm:!
32

43
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.
76

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.
128

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 .
2713
```
2814

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.
3023

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
3129
`'<Button-4>'`, `'<Button-5>'` and `'<MouseWheel>'` are bound to all widgets using `bind_all` to handle mouse wheel
3230
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).

examples/examples_ScrollablePanelWx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def grid_of_widgets():
1717
# Add widgets to the `panel` attribute of the scrollable panel, not to the
1818
# scrollable panel itself.
1919
dim = 10
20-
grid_sizer = wx.GridSizer(dim, dim, 10, 10)
20+
grid_sizer = wx.GridSizer(dim, dim, 20, 20)
2121
for (i, j) in itertools.product(range(dim), range(dim)):
2222
grid_sizer.Add(wx.StaticText(scrollable_panel.panel, label=f'Label\n({i}, {j})'))
2323

0 commit comments

Comments
 (0)