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