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