]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/ScrolledPanel.py
Reverted to old method names/signatures for wx.DC, updated lib and
[wxWidgets.git] / wxPython / demo / ScrolledPanel.py
CommitLineData
8fa876ca
RD
1
2import wx
95bfd958 3import wx.lib.scrolledpanel as scrolled
1e4a197e
RD
4
5#----------------------------------------------------------------------
6
7text = "one two buckle my shoe three four shut the door five six pick up sticks seven eight lay them straight nine ten big fat hen"
8
9
d4b73b1b 10class TestPanel(scrolled.ScrolledPanel):
1e4a197e
RD
11 def __init__(self, parent, log):
12 self.log = log
d4b73b1b 13 scrolled.ScrolledPanel.__init__(self, parent, -1)
1e4a197e 14
8fa876ca
RD
15 vbox = wx.BoxSizer(wx.VERTICAL)
16 desc = wx.StaticText(self, -1,
299647ac 17 "ScrolledPanel extends wx.ScrolledWindow, adding all "
1e4a197e 18 "the necessary bits to set up scroll handling for you.\n\n"
1fded56b 19 "Here are three fixed size examples of its use. The "
95bfd958 20 "demo panel for this sample is also using it -- the \nwxStaticLine "
1fded56b
RD
21 "below is intentionally made too long so a scrollbar will be "
22 "activated."
1e4a197e
RD
23 )
24 desc.SetForegroundColour("Blue")
8fa876ca
RD
25 vbox.Add(desc, 0, wx.ALIGN_LEFT|wx.ALL, 5)
26 vbox.Add(wx.StaticLine(self, -1, size=(1024,-1)), 0, wx.ALL, 5)
fd3f2efe 27 vbox.Add((20,20))
1e4a197e
RD
28
29 words = text.split()
30
d4b73b1b 31 panel1 = scrolled.ScrolledPanel(self, -1, size=(120,300),
8fa876ca
RD
32 style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER )
33 fgs1 = wx.FlexGridSizer(cols=2, vgap=4, hgap=4)
1e4a197e
RD
34
35 for word in words:
8fa876ca
RD
36 label = wx.StaticText(panel1, -1, word+":")
37 tc = wx.TextCtrl(panel1, -1, word, size=(50,-1))
38 fgs1.Add(label, flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
39 fgs1.Add(tc, flag=wx.EXPAND|wx.RIGHT, border=25)
1e4a197e
RD
40
41 panel1.SetSizer( fgs1 )
42 panel1.SetAutoLayout(1)
43 panel1.SetupScrolling( scroll_x=False )
44
d4b73b1b 45 panel2 = scrolled.ScrolledPanel(self, -1, size=(350, 40),
8fa876ca 46 style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER)
d4b73b1b 47 panel3 = scrolled.ScrolledPanel(self, -1, size=(200,100),
8fa876ca 48 style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER)
1e4a197e 49
8fa876ca
RD
50 fgs2 = wx.FlexGridSizer(cols=25, vgap=4, hgap=4)
51 fgs3 = wx.FlexGridSizer(cols=5, vgap=4, hgap=4)
1e4a197e
RD
52
53 for i in range(len(words)):
54 word = words[i]
55 if i % 5 != 4:
8fa876ca
RD
56 label2 = wx.StaticText(panel2, -1, word)
57 fgs2.Add(label2, flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
58 label3 = wx.StaticText(panel3, -1, word)
59 fgs3.Add(label3, flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
1e4a197e 60 else:
8fa876ca
RD
61 tc2 = wx.TextCtrl(panel2, -1, word, size=(50,-1))
62 fgs2.Add(tc2, flag=wx.LEFT, border=5)
63 tc3 = wx.TextCtrl(panel3, -1, word )
64 fgs3.Add(tc3, flag=wx.LEFT, border=5)
1e4a197e
RD
65
66 panel2.SetSizer( fgs2 )
67 panel2.SetAutoLayout(1)
68 panel2.SetupScrolling(scroll_y = False)
69
70 panel3.SetSizer( fgs3 )
71 panel3.SetAutoLayout(1)
72 panel3.SetupScrolling()
73
372bde9b 74 hbox = wx.BoxSizer(wx.HORIZONTAL)
fd3f2efe 75 hbox.Add((20,20))
1e4a197e 76 hbox.Add(panel1, 0)
fd3f2efe 77 hbox.Add((40, 10))
1e4a197e 78
8fa876ca 79 vbox2 = wx.BoxSizer(wx.VERTICAL)
1e4a197e 80 vbox2.Add(panel2, 0)
fd3f2efe 81 vbox2.Add((20, 50))
1e4a197e
RD
82
83 vbox2.Add(panel3, 0)
fd3f2efe 84 vbox2.Add((20, 10))
1e4a197e
RD
85 hbox.Add(vbox2)
86
d7403ad2 87 vbox.Add(hbox, 0)
1e4a197e
RD
88 self.SetSizer(vbox)
89 self.SetAutoLayout(1)
90 self.SetupScrolling()
91
92
93#----------------------------------------------------------------------
94
95
96def runTest(frame, nb, log):
97 win = TestPanel(nb, log)
98 return win
99
100#----------------------------------------------------------------------
101
102
103
104overview = """<html><body>
299647ac 105ScrolledPanel fills a "hole" in the implementation of wx.ScrolledWindow,
1e4a197e 106providing automatic scrollbar and scrolling behavior and the tab traversal
299647ac 107mangement that wx.ScrolledWindow lacks.
1e4a197e
RD
108</body></html>
109"""
110
111
112if __name__ == '__main__':
113 import sys,os
114 import run
8eca4fef 115 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])