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