]>
Commit | Line | Data |
---|---|---|
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 | # 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) | |
14 | # | |
15 | # o wxScrolledPanel -> ScrolledPanel | |
16 | # | |
17 | ||
18 | import wx | |
19 | import wx.lib.scrolledpanel as scrolled | |
20 | ||
21 | #---------------------------------------------------------------------- | |
22 | ||
23 | 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" | |
24 | ||
25 | ||
26 | class TestPanel(scrolled.ScrolledPanel): | |
27 | def __init__(self, parent, log): | |
28 | self.log = log | |
29 | scrolled.ScrolledPanel.__init__(self, parent, -1) | |
30 | ||
31 | vbox = wx.BoxSizer(wx.VERTICAL) | |
32 | desc = wx.StaticText(self, -1, | |
33 | "ScrolledPanel extends wxScrolledWindow, adding all " | |
34 | "the necessary bits to set up scroll handling for you.\n\n" | |
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." | |
39 | ) | |
40 | desc.SetForegroundColour("Blue") | |
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) | |
43 | vbox.Add((20,20)) | |
44 | ||
45 | words = text.split() | |
46 | ||
47 | panel1 = scrolled.ScrolledPanel(self, -1, size=(120,300), | |
48 | style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER ) | |
49 | fgs1 = wx.FlexGridSizer(cols=2, vgap=4, hgap=4) | |
50 | ||
51 | for word in words: | |
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) | |
56 | ||
57 | panel1.SetSizer( fgs1 ) | |
58 | panel1.SetAutoLayout(1) | |
59 | panel1.SetupScrolling( scroll_x=False ) | |
60 | ||
61 | panel2 = scrolled.ScrolledPanel(self, -1, size=(350, 40), | |
62 | style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER) | |
63 | panel3 = scrolled.ScrolledPanel(self, -1, size=(200,100), | |
64 | style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER) | |
65 | ||
66 | fgs2 = wx.FlexGridSizer(cols=25, vgap=4, hgap=4) | |
67 | fgs3 = wx.FlexGridSizer(cols=5, vgap=4, hgap=4) | |
68 | ||
69 | for i in range(len(words)): | |
70 | word = words[i] | |
71 | if i % 5 != 4: | |
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) | |
76 | else: | |
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) | |
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 | ||
90 | hbox = wx.BoxSizer(wx.HORIZONTAL) | |
91 | hbox.Add((20,20)) | |
92 | hbox.Add(panel1, 0) | |
93 | hbox.Add((40, 10)) | |
94 | ||
95 | vbox2 = wx.BoxSizer(wx.VERTICAL) | |
96 | vbox2.Add(panel2, 0) | |
97 | vbox2.Add((20, 50)) | |
98 | ||
99 | vbox2.Add(panel3, 0) | |
100 | vbox2.Add((20, 10)) | |
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 | ||
112 | def runTest(frame, nb, log): | |
113 | win = TestPanel(nb, log) | |
114 | return win | |
115 | ||
116 | #---------------------------------------------------------------------- | |
117 | ||
118 | ||
119 | ||
120 | overview = """<html><body> | |
121 | ScrolledPanel fills a "hole" in the implementation of wxScrolledWindow, | |
122 | providing automatic scrollbar and scrolling behavior and the tab traversal | |
123 | mangement that wxScrolledWindow lacks. | |
124 | </body></html> | |
125 | """ | |
126 | ||
127 | ||
128 | if __name__ == '__main__': | |
129 | import sys,os | |
130 | import run | |
131 | run.main(['', os.path.basename(sys.argv[0])]) |