]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxScrolledPanel.py
Added wxAutoNSAutoreleasePool to Create(Tool|Status)Bar
[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
10 import wx
11 import wx.lib.scrolledpanel as scrolled
12
13 #----------------------------------------------------------------------
14
15 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"
16
17
18 class TestPanel(scrolled.wxScrolledPanel):
19 def __init__(self, parent, log):
20 self.log = log
21 scrolled.wxScrolledPanel.__init__(self, parent, -1)
22
23 vbox = wx.BoxSizer(wx.VERTICAL)
24 desc = wx.StaticText(self, -1,
25 "wxScrolledPanel extends wxScrolledWindow, adding all "
26 "the necessary bits to set up scroll handling for you.\n\n"
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."
31 )
32 desc.SetForegroundColour("Blue")
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)
35 vbox.Add((20,20))
36
37 words = text.split()
38
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)
42
43 for word in words:
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)
48
49 panel1.SetSizer( fgs1 )
50 panel1.SetAutoLayout(1)
51 panel1.SetupScrolling( scroll_x=False )
52
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)
57
58 fgs2 = wx.FlexGridSizer(cols=25, vgap=4, hgap=4)
59 fgs3 = wx.FlexGridSizer(cols=5, vgap=4, hgap=4)
60
61 for i in range(len(words)):
62 word = words[i]
63 if i % 5 != 4:
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)
68 else:
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)
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 = wx.BoxSizer(wx.HORIZONTAL)
83 hbox.Add((20,20))
84 hbox.Add(panel1, 0)
85 hbox.Add((40, 10))
86
87 vbox2 = wx.BoxSizer(wx.VERTICAL)
88 vbox2.Add(panel2, 0)
89 vbox2.Add((20, 50))
90
91 vbox2.Add(panel3, 0)
92 vbox2.Add((20, 10))
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
104 def runTest(frame, nb, log):
105 win = TestPanel(nb, log)
106 return win
107
108 #----------------------------------------------------------------------
109
110
111
112 overview = """<html><body>
113 wxScrolledPanel fills a "hole" in the implementation of wxScrolledWindow,
114 providing automatic scrollbar and scrolling behavior and the tab traversal
115 mangement that wxScrolledWindow lacks.
116 </body></html>
117 """
118
119
120 if __name__ == '__main__':
121 import sys,os
122 import run
123 run.main(['', os.path.basename(sys.argv[0])])