Skip to content

Commit 2baad68

Browse files
committed
Added examples for wxPython.
1 parent 0c32e4c commit 2baad68

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

ScrollableContainers/Wx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ def __init__(self, *args, **kwargs):
2020
# minimum virtual size of the panel.
2121
vbox = wx.BoxSizer(wx.VERTICAL)
2222
self.panel = wx.Panel(self)
23-
vbox.Add(self.panel, flag=wx.ALIGN_CENTRE | wx.EXPAND)
23+
vbox.Add(self.panel, flag=wx.ALIGN_CENTRE)
2424
self.SetSizer(vbox)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#! /usr/bin/python3 -B
2+
3+
import itertools
4+
import wx
5+
6+
from ScrollableContainers.Wx import ScrollablePanelWx
7+
8+
###############################################################################
9+
10+
def grid_of_widgets():
11+
app = wx.App()
12+
root = wx.Frame(None, title='`ScrollablePanelWx` Demo')
13+
14+
# Create a scrollable panel.
15+
scrollable_panel = ScrollablePanelWx(root)
16+
17+
# Add widgets to the `panel` attribute of the scrollable panel, not to the
18+
# scrollable panel itself.
19+
dim = 10
20+
grid_sizer = wx.GridSizer(dim, dim, 10, 10)
21+
for (i, j) in itertools.product(range(dim), range(dim)):
22+
grid_sizer.Add(wx.StaticText(scrollable_panel.panel, label=f'Label\n({i}, {j})'))
23+
24+
scrollable_panel.panel.SetSizer(grid_sizer)
25+
scrollable_panel.SetupScrolling()
26+
root.Show()
27+
app.MainLoop()
28+
29+
###############################################################################
30+
31+
def single_widget():
32+
app = wx.App()
33+
root = wx.Frame(None, title='`ScrollablePanelWx` Demo', size=(600, 200))
34+
35+
scrollable_panel = ScrollablePanelWx(root)
36+
37+
wx.StaticText(scrollable_panel.panel, label='bing window, small label')
38+
39+
scrollable_panel.SetupScrolling()
40+
root.Show()
41+
app.MainLoop()
42+
43+
###############################################################################
44+
45+
if __name__ == '__main__':
46+
grid_of_widgets()
47+
single_widget()

0 commit comments

Comments
 (0)