]>
Commit | Line | Data |
---|---|---|
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 | # | |
8fa876ca RD |
13 | |
14 | import wx | |
15 | import wx.lib.scrolledpanel as scrolled | |
1e4a197e RD |
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 | ||
8fa876ca | 22 | class TestPanel(scrolled.wxScrolledPanel): |
1e4a197e RD |
23 | def __init__(self, parent, log): |
24 | self.log = log | |
8fa876ca | 25 | scrolled.wxScrolledPanel.__init__(self, parent, -1) |
1e4a197e | 26 | |
8fa876ca RD |
27 | vbox = wx.BoxSizer(wx.VERTICAL) |
28 | desc = wx.StaticText(self, -1, | |
1e4a197e RD |
29 | "wxScrolledPanel extends wxScrolledWindow, adding all " |
30 | "the necessary bits to set up scroll handling for you.\n\n" | |
1fded56b RD |
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." | |
1e4a197e RD |
35 | ) |
36 | desc.SetForegroundColour("Blue") | |
8fa876ca RD |
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) | |
fd3f2efe | 39 | vbox.Add((20,20)) |
1e4a197e RD |
40 | |
41 | words = text.split() | |
42 | ||
8fa876ca RD |
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) | |
1e4a197e RD |
46 | |
47 | for word in words: | |
8fa876ca RD |
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) | |
1e4a197e RD |
52 | |
53 | panel1.SetSizer( fgs1 ) | |
54 | panel1.SetAutoLayout(1) | |
55 | panel1.SetupScrolling( scroll_x=False ) | |
56 | ||
8fa876ca RD |
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) | |
1e4a197e | 61 | |
8fa876ca RD |
62 | fgs2 = wx.FlexGridSizer(cols=25, vgap=4, hgap=4) |
63 | fgs3 = wx.FlexGridSizer(cols=5, vgap=4, hgap=4) | |
1e4a197e RD |
64 | |
65 | for i in range(len(words)): | |
66 | word = words[i] | |
67 | if i % 5 != 4: | |
8fa876ca RD |
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) | |
1e4a197e | 72 | else: |
8fa876ca RD |
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) | |
1e4a197e RD |
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 | ||
372bde9b | 86 | hbox = wx.BoxSizer(wx.HORIZONTAL) |
fd3f2efe | 87 | hbox.Add((20,20)) |
1e4a197e | 88 | hbox.Add(panel1, 0) |
fd3f2efe | 89 | hbox.Add((40, 10)) |
1e4a197e | 90 | |
8fa876ca | 91 | vbox2 = wx.BoxSizer(wx.VERTICAL) |
1e4a197e | 92 | vbox2.Add(panel2, 0) |
fd3f2efe | 93 | vbox2.Add((20, 50)) |
1e4a197e RD |
94 | |
95 | vbox2.Add(panel3, 0) | |
fd3f2efe | 96 | vbox2.Add((20, 10)) |
1e4a197e RD |
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 | |
8fa876ca | 119 | mangement that wxScrolledWindow lacks. |
1e4a197e RD |
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])]) |