]>
Commit | Line | Data |
---|---|---|
1 | ||
2 | import wx | |
3 | import wx.lib.foldpanelbar as fpb | |
4 | ||
5 | ||
6 | # ---------------------------------------------------------------------------- | |
7 | # Extended Demo Implementation | |
8 | # | |
9 | # This demo shows how to use custom CaptionBar styles and custom icons for | |
10 | # the caption bars. here i used the standard Windows XP icons for the | |
11 | # collapsed and expanded state. | |
12 | # ---------------------------------------------------------------------------- | |
13 | ||
14 | #---------------------------------------------------------------------- | |
15 | # different icons for the collapsed/expanded states. | |
16 | # Taken from standard Windows XP collapsed/expanded states. | |
17 | #---------------------------------------------------------------------- | |
18 | ||
19 | def GetCollapsedIconData(): | |
20 | return \ | |
21 | '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\ | |
22 | \x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\ | |
23 | \x00\x01\x8eIDAT8\x8d\xa5\x93-n\xe4@\x10\x85?g\x03\n6lh)\xc4\xd2\x12\xc3\x81\ | |
24 | \xd6\xa2I\x90\x154\xb9\x81\x8f1G\xc8\x11\x16\x86\xcd\xa0\x99F\xb3A\x91\xa1\ | |
25 | \xc9J&\x96L"5lX\xcc\x0bl\xf7v\xb2\x7fZ\xa5\x98\xebU\xbdz\xf5\\\x9deW\x9f\xf8\ | |
26 | H\\\xbfO|{y\x9dT\x15P\x04\x01\x01UPUD\x84\xdb/7YZ\x9f\xa5\n\xce\x97aRU\x8a\ | |
27 | \xdc`\xacA\x00\x04P\xf0!0\xf6\x81\xa0\xf0p\xff9\xfb\x85\xe0|\x19&T)K\x8b\x18\ | |
28 | \xf9\xa3\xe4\xbe\xf3\x8c^#\xc9\xd5\n\xa8*\xc5?\x9a\x01\x8a\xd2b\r\x1cN\xc3\ | |
29 | \x14\t\xce\x97a\xb2F0Ks\xd58\xaa\xc6\xc5\xa6\xf7\xdfya\xe7\xbdR\x13M2\xf9\ | |
30 | \xf9qKQ\x1fi\xf6-\x00~T\xfac\x1dq#\x82,\xe5q\x05\x91D\xba@\xefj\xba1\xf0\xdc\ | |
31 | zzW\xcff&\xb8,\x89\xa8@Q\xd6\xaaf\xdfRm,\xee\xb1BDxr#\xae\xf5|\xddo\xd6\xe2H\ | |
32 | \x18\x15\x84\xa0q@]\xe54\x8d\xa3\xedf\x05M\xe3\xd8Uy\xc4\x15\x8d\xf5\xd7\x8b\ | |
33 | ~\x82\x0fh\x0e"\xb0\xad,\xee\xb8c\xbb\x18\xe7\x8e;6\xa5\x89\x04\xde\xff\x1c\ | |
34 | \x16\xef\xe0p\xfa>\x19\x11\xca\x8d\x8d\xe0\x93\x1b\x01\xd8m\xf3(;x\xa5\xef=\ | |
35 | \xb7w\xf3\x1d$\x7f\xc1\xe0\xbd\xa7\xeb\xa0(,"Kc\x12\xc1+\xfd\xe8\tI\xee\xed)\ | |
36 | \xbf\xbcN\xc1{D\x04k\x05#\x12\xfd\xf2a\xde[\x81\x87\xbb\xdf\x9cr\x1a\x87\xd3\ | |
37 | 0)\xba>\x83\xd5\xb97o\xe0\xaf\x04\xff\x13?\x00\xd2\xfb\xa9`z\xac\x80w\x00\ | |
38 | \x00\x00\x00IEND\xaeB`\x82' | |
39 | ||
40 | def GetCollapsedIconBitmap(): | |
41 | return wx.BitmapFromImage(GetCollapsedIconImage()) | |
42 | ||
43 | def GetCollapsedIconImage(): | |
44 | import cStringIO | |
45 | stream = cStringIO.StringIO(GetCollapsedIconData()) | |
46 | return wx.ImageFromStream(stream) | |
47 | ||
48 | #---------------------------------------------------------------------- | |
49 | def GetExpandedIconData(): | |
50 | return \ | |
51 | '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\ | |
52 | \x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\ | |
53 | \x00\x01\x9fIDAT8\x8d\x95\x93\xa1\x8e\xdc0\x14EO\xb2\xc4\xd0\xd2\x12\xb7(mI\ | |
54 | \xa4%V\xd1lQT4[4-\x9a\xfe\xc1\xc2|\xc6\xc2~BY\x83:A3E\xd3\xa0*\xa4\xd2\x90H!\ | |
55 | \x95\x0c\r\r\x1fK\x81g\xb2\x99\x84\xb4\x0fY\xd6\xbb\xc7\xf7>=\'Iz\xc3\xbcv\ | |
56 | \xfbn\xb8\x9c\x15 \xe7\xf3\xc7\x0fw\xc9\xbc7\x99\x03\x0e\xfbn0\x99F+\x85R\ | |
57 | \x80RH\x10\x82\x08\xde\x05\x1ef\x90+\xc0\xe1\xd8\ryn\xd0Z-\\A\xb4\xd2\xf7\ | |
58 | \x9e\xfbwoF\xc8\x088\x1c\xbbae\xb3\xe8y&\x9a\xdf\xf5\xbd\xe7\xfem\x84\xa4\ | |
59 | \x97\xccYf\x16\x8d\xdb\xb2a]\xfeX\x18\xc9s\xc3\xe1\x18\xe7\x94\x12cb\xcc\xb5\ | |
60 | \xfa\xb1l8\xf5\x01\xe7\x84\xc7\xb2Y@\xb2\xcc0\x02\xb4\x9a\x88%\xbe\xdc\xb4\ | |
61 | \x9e\xb6Zs\xaa74\xadg[6\x88<\xb7]\xc6\x14\x1dL\x86\xe6\x83\xa0\x81\xba\xda\ | |
62 | \x10\x02x/\xd4\xd5\x06\r\x840!\x9c\x1fM\x92\xf4\x86\x9f\xbf\xfe\x0c\xd6\x9ae\ | |
63 | \xd6u\x8d \xf4\xf5\x165\x9b\x8f\x04\xe1\xc5\xcb\xdb$\x05\x90\xa97@\x04lQas\ | |
64 | \xcd*7\x14\xdb\x9aY\xcb\xb8\\\xe9E\x10|\xbc\xf2^\xb0E\x85\xc95_\x9f\n\xaa/\ | |
65 | \x05\x10\x81\xce\xc9\xa8\xf6><G\xd8\xed\xbbA)X\xd9\x0c\x01\x9a\xc6Q\x14\xd9h\ | |
66 | [\x04\xda\xd6c\xadFkE\xf0\xc2\xab\xd7\xb7\xc9\x08\x00\xf8\xf6\xbd\x1b\x8cQ\ | |
67 | \xd8|\xb9\x0f\xd3\x9a\x8a\xc7\x08\x00\x9f?\xdd%\xde\x07\xda\x93\xc3{\x19C\ | |
68 | \x8a\x9c\x03\x0b8\x17\xe8\x9d\xbf\x02.>\x13\xc0n\xff{PJ\xc5\xfdP\x11""<\xbc\ | |
69 | \xff\x87\xdf\xf8\xbf\xf5\x17FF\xaf\x8f\x8b\xd3\xe6K\x00\x00\x00\x00IEND\xaeB\ | |
70 | `\x82' | |
71 | ||
72 | def GetExpandedIconBitmap(): | |
73 | return wx.BitmapFromImage(GetExpandedIconImage()) | |
74 | ||
75 | def GetExpandedIconImage(): | |
76 | import cStringIO | |
77 | stream = cStringIO.StringIO(GetExpandedIconData()) | |
78 | return wx.ImageFromStream(stream) | |
79 | ||
80 | #---------------------------------------------------------------------- | |
81 | def GetMondrianData(): | |
82 | return \ | |
83 | '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ | |
84 | \x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x00qID\ | |
85 | ATX\x85\xed\xd6;\n\x800\x10E\xd1{\xc5\x8d\xb9r\x97\x16\x0b\xad$\x8a\x82:\x16\ | |
86 | o\xda\x84pB2\x1f\x81Fa\x8c\x9c\x08\x04Z{\xcf\xa72\xbcv\xfa\xc5\x08 \x80r\x80\ | |
87 | \xfc\xa2\x0e\x1c\xe4\xba\xfaX\x1d\xd0\xde]S\x07\x02\xd8>\xe1wa-`\x9fQ\xe9\ | |
88 | \x86\x01\x04\x10\x00\\(Dk\x1b-\x04\xdc\x1d\x07\x14\x98;\x0bS\x7f\x7f\xf9\x13\ | |
89 | \x04\x10@\xf9X\xbe\x00\xc9 \x14K\xc1<={\x00\x00\x00\x00IEND\xaeB`\x82' | |
90 | ||
91 | def GetMondrianBitmap(): | |
92 | return wx.BitmapFromImage(GetMondrianImage()) | |
93 | ||
94 | def GetMondrianImage(): | |
95 | import cStringIO | |
96 | stream = cStringIO.StringIO(GetMondrianData()) | |
97 | return wx.ImageFromStream(stream) | |
98 | ||
99 | def GetMondrianIcon(): | |
100 | icon = wx.EmptyIcon() | |
101 | icon.CopyFromBitmap(GetMondrianBitmap()) | |
102 | return icon | |
103 | ||
104 | # ---------------------------------------------------------------------------- | |
105 | # Beginning Of Extended Demo | |
106 | # ---------------------------------------------------------------------------- | |
107 | ||
108 | class Extended(wx.Frame): | |
109 | ||
110 | def __init__(self, parent, id=wx.ID_ANY, title="", pos=wx.DefaultPosition, | |
111 | size=(700,650), style=wx.DEFAULT_FRAME_STYLE): | |
112 | ||
113 | wx.Frame.__init__(self, parent, id, title, pos, size, style) | |
114 | ||
115 | self._flags = 0 | |
116 | ||
117 | self.SetIcon(GetMondrianIcon()) | |
118 | self.SetMenuBar(self.CreateMenuBar()) | |
119 | ||
120 | self.statusbar = self.CreateStatusBar(2, wx.ST_SIZEGRIP) | |
121 | self.statusbar.SetStatusWidths([-4, -3]) | |
122 | self.statusbar.SetStatusText("Andrea Gavana @ 23 Mar 2005", 0) | |
123 | self.statusbar.SetStatusText("Welcome to wxPython!", 1) | |
124 | ||
125 | self._leftWindow1 = wx.SashLayoutWindow(self, 101, wx.DefaultPosition, | |
126 | wx.Size(200, 1000), wx.NO_BORDER | | |
127 | wx.SW_3D | wx.CLIP_CHILDREN) | |
128 | ||
129 | self._leftWindow1.SetDefaultSize(wx.Size(220, 1000)) | |
130 | self._leftWindow1.SetOrientation(wx.LAYOUT_VERTICAL) | |
131 | self._leftWindow1.SetAlignment(wx.LAYOUT_LEFT) | |
132 | self._leftWindow1.SetSashVisible(wx.SASH_RIGHT, True) | |
133 | self._leftWindow1.SetExtraBorderSize(10) | |
134 | ||
135 | self._pnl = 0 | |
136 | ||
137 | # will occupy the space not used by the Layout Algorithm | |
138 | self.remainingSpace = wx.Panel(self, -1, style=wx.SUNKEN_BORDER) | |
139 | wx.StaticText(self.remainingSpace, -1, | |
140 | "Use your imagination for what kinds of things to put in this window...", | |
141 | (15,30)) | |
142 | ||
143 | self.ID_WINDOW_TOP = 100 | |
144 | self.ID_WINDOW_LEFT1 = 101 | |
145 | self.ID_WINDOW_RIGHT1 = 102 | |
146 | self.ID_WINDOW_BOTTOM = 103 | |
147 | ||
148 | self._leftWindow1.Bind(wx.EVT_SASH_DRAGGED_RANGE, self.OnFoldPanelBarDrag, | |
149 | id=100, id2=103) | |
150 | self.Bind(wx.EVT_SIZE, self.OnSize) | |
151 | self.Bind(wx.EVT_SCROLL, self.OnSlideColour) | |
152 | ||
153 | self.ReCreateFoldPanel(0) | |
154 | ||
155 | ||
156 | def OnSize(self, event): | |
157 | ||
158 | wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace) | |
159 | event.Skip() | |
160 | ||
161 | ||
162 | def OnQuit(self, event): | |
163 | ||
164 | self.Destroy() | |
165 | ||
166 | ||
167 | def OnAbout(self, event): | |
168 | ||
169 | msg = "This is the about dialog of the FoldPanelBar demo.\n\n" + \ | |
170 | "Author: Andrea Gavana @ 23 Mar 2005\n\n" + \ | |
171 | "Please report any bug/requests or improvements\n" + \ | |
172 | "To me at the following adresses:\n\n" + \ | |
173 | "andrea.gavana@agip.it\n" + "andrea_gavana@tin.it\n\n" + \ | |
174 | "Based On Julian Smart C++ demo implementation.\n\n" + \ | |
175 | "Welcome To wxPython " + wx.VERSION_STRING + "!!" | |
176 | ||
177 | dlg = wx.MessageDialog(self, msg, "FoldPanelBar Extended Demo", | |
178 | wx.OK | wx.ICON_INFORMATION) | |
179 | dlg.SetFont(wx.Font(8, wx.NORMAL, wx.NORMAL, wx.NORMAL, False, "Verdana")) | |
180 | dlg.ShowModal() | |
181 | dlg.Destroy() | |
182 | ||
183 | ||
184 | def OnToggleWindow(self, event): | |
185 | ||
186 | self._leftWindow1.Show(not self._leftWindow1.IsShown()) | |
187 | # Leaves bits of itself behind sometimes | |
188 | wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace) | |
189 | self.remainingSpace.Refresh() | |
190 | ||
191 | event.Skip() | |
192 | ||
193 | ||
194 | def OnFoldPanelBarDrag(self, event): | |
195 | ||
196 | if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE: | |
197 | return | |
198 | ||
199 | if event.GetId() == self.ID_WINDOW_LEFT1: | |
200 | self._leftWindow1.SetDefaultSize(wx.Size(event.GetDragRect().width, 1000)) | |
201 | ||
202 | ||
203 | # Leaves bits of itself behind sometimes | |
204 | wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace) | |
205 | self.remainingSpace.Refresh() | |
206 | ||
207 | event.Skip() | |
208 | ||
209 | ||
210 | def ReCreateFoldPanel(self, fpb_flags): | |
211 | ||
212 | # delete earlier panel | |
213 | self._leftWindow1.DestroyChildren() | |
214 | ||
215 | # recreate the foldpanelbar | |
216 | ||
217 | self._pnl = fpb.FoldPanelBar(self._leftWindow1, -1, wx.DefaultPosition, | |
218 | wx.Size(-1,-1), fpb.FPB_DEFAULT_STYLE, fpb_flags) | |
219 | ||
220 | Images = wx.ImageList(16,16) | |
221 | Images.Add(GetExpandedIconBitmap()) | |
222 | Images.Add(GetCollapsedIconBitmap()) | |
223 | ||
224 | item = self._pnl.AddFoldPanel("Caption Colours", collapsed=False, | |
225 | foldIcons=Images) | |
226 | ||
227 | self._pnl.AddFoldPanelWindow(item, wx.StaticText(item, -1, "Adjust The First Colour"), | |
228 | fpb.FPB_ALIGN_WIDTH, 5, 20) | |
229 | ||
230 | # RED color spin control | |
231 | self._rslider1 = wx.Slider(item, -1, 0, 0, 255) | |
232 | self._pnl.AddFoldPanelWindow(item, self._rslider1, fpb.FPB_ALIGN_WIDTH, 2, 20) | |
233 | ||
234 | # GREEN color spin control | |
235 | self._gslider1 = wx.Slider(item, -1, 0, 0, 255) | |
236 | self._pnl.AddFoldPanelWindow(item, self._gslider1, fpb.FPB_ALIGN_WIDTH, 0, 20) | |
237 | ||
238 | # BLUE color spin control | |
239 | self._bslider1 = wx.Slider(item, -1, 0, 0, 255) | |
240 | self._pnl.AddFoldPanelWindow(item, self._bslider1, fpb.FPB_ALIGN_WIDTH, 0, 20) | |
241 | ||
242 | self._pnl.AddFoldPanelSeparator(item) | |
243 | ||
244 | self._pnl.AddFoldPanelWindow(item, wx.StaticText(item, -1, "Adjust The Second Colour"), | |
245 | fpb.FPB_ALIGN_WIDTH, 5, 20) | |
246 | ||
247 | # RED color spin control | |
248 | self._rslider2 = wx.Slider(item, -1, 0, 0, 255) | |
249 | self._pnl.AddFoldPanelWindow(item, self._rslider2, fpb.FPB_ALIGN_WIDTH, 2, 20) | |
250 | ||
251 | # GREEN color spin control | |
252 | self._gslider2 = wx.Slider(item, -1, 0, 0, 255) | |
253 | self._pnl.AddFoldPanelWindow(item, self._gslider2, fpb.FPB_ALIGN_WIDTH, 0, 20) | |
254 | ||
255 | # BLUE color spin control | |
256 | self._bslider2 = wx.Slider(item, -1, 0, 0, 255) | |
257 | self._pnl.AddFoldPanelWindow(item, self._bslider2, fpb.FPB_ALIGN_WIDTH, 0, 20) | |
258 | ||
259 | self._pnl.AddFoldPanelSeparator(item) | |
260 | ||
261 | button1 = wx.Button(item, wx.ID_ANY, "Apply To All") | |
262 | button1.Bind(wx.EVT_BUTTON, self.OnExpandMe) | |
263 | self._pnl.AddFoldPanelWindow(item, button1) | |
264 | ||
265 | # read back current gradients and set the sliders | |
266 | # for the colour which is now taken as default | |
267 | ||
268 | style = self._pnl.GetCaptionStyle(item) | |
269 | col = style.GetFirstColour() | |
270 | ||
271 | self._rslider1.SetValue(col.Red()) | |
272 | self._gslider1.SetValue(col.Green()) | |
273 | self._bslider1.SetValue(col.Blue()) | |
274 | ||
275 | col = style.GetSecondColour() | |
276 | self._rslider2.SetValue(col.Red()) | |
277 | self._gslider2.SetValue(col.Green()) | |
278 | self._bslider2.SetValue(col.Blue()) | |
279 | ||
280 | # put down some caption styles from which the user can | |
281 | # select to show how the current or all caption bars will look like | |
282 | ||
283 | item = self._pnl.AddFoldPanel("Caption Style", False, foldIcons=Images) | |
284 | ||
285 | self.ID_USE_VGRADIENT = wx.NewId() | |
286 | self.ID_USE_HGRADIENT = wx.NewId() | |
287 | self.ID_USE_SINGLE = wx.NewId() | |
288 | self.ID_USE_RECTANGLE = wx.NewId() | |
289 | self.ID_USE_FILLED_RECTANGLE = wx.NewId() | |
290 | ||
291 | currStyle = wx.RadioButton(item, self.ID_USE_VGRADIENT, "&Vertical Gradient") | |
292 | self._pnl.AddFoldPanelWindow(item, currStyle, fpb.FPB_ALIGN_WIDTH, | |
293 | fpb.FPB_DEFAULT_SPACING, 10) | |
294 | ||
295 | currStyle.SetValue(True) | |
296 | ||
297 | radio1 = wx.RadioButton(item, self.ID_USE_HGRADIENT, "&Horizontal Gradient") | |
298 | radio2 = wx.RadioButton(item, self.ID_USE_SINGLE, "&Single Colour") | |
299 | radio3 = wx.RadioButton(item, self.ID_USE_RECTANGLE, "&Rectangle Box") | |
300 | radio4 = wx.RadioButton(item, self.ID_USE_FILLED_RECTANGLE, "&Filled Rectangle Box") | |
301 | ||
302 | currStyle.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange) | |
303 | radio1.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange) | |
304 | radio2.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange) | |
305 | radio3.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange) | |
306 | radio4.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange) | |
307 | ||
308 | self._pnl.AddFoldPanelWindow(item, radio1, fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 10) | |
309 | self._pnl.AddFoldPanelWindow(item, radio2, fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 10) | |
310 | self._pnl.AddFoldPanelWindow(item, radio3, fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 10) | |
311 | self._pnl.AddFoldPanelWindow(item, radio4, fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 10) | |
312 | ||
313 | self._pnl.AddFoldPanelSeparator(item) | |
314 | ||
315 | self._single = wx.CheckBox(item, -1, "&Only This Caption") | |
316 | self._pnl.AddFoldPanelWindow(item, self._single, fpb.FPB_ALIGN_WIDTH, | |
317 | fpb.FPB_DEFAULT_SPACING, 10) | |
318 | ||
319 | # one more panel to finish it | |
320 | ||
321 | cs = fpb.CaptionBarStyle() | |
322 | cs.SetCaptionStyle(fpb.CAPTIONBAR_RECTANGLE) | |
323 | ||
324 | item = self._pnl.AddFoldPanel("Misc Stuff", collapsed=True, foldIcons=Images, | |
325 | cbstyle=cs) | |
326 | ||
327 | button2 = wx.Button(item, wx.NewId(), "Collapse All") | |
328 | self._pnl.AddFoldPanelWindow(item, button2) | |
329 | self._pnl.AddFoldPanelWindow(item, wx.StaticText(item, -1, "Enter Some Comments"), | |
330 | fpb.FPB_ALIGN_WIDTH, 5, 20) | |
331 | self._pnl.AddFoldPanelWindow(item, wx.TextCtrl(item, -1, "Comments"), | |
332 | fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 10) | |
333 | ||
334 | button2.Bind(wx.EVT_BUTTON, self.OnCollapseMe) | |
335 | self.radiocontrols = [currStyle, radio1, radio2, radio3, radio4] | |
336 | ||
337 | self._leftWindow1.SizeWindows() | |
338 | ||
339 | ||
340 | def OnCreateBottomStyle(self, event): | |
341 | ||
342 | # recreate with style collapse to bottom, which means | |
343 | # all panels that are collapsed are placed at the bottom, | |
344 | # or normal | |
345 | ||
346 | if event.IsChecked(): | |
347 | self.GetMenuBar().Check(self._singlestyle, False) | |
348 | self.GetMenuBar().Check(self._exclusivestyle, False) | |
349 | self._flags = self._flags & ~fpb.FPB_SINGLE_FOLD | |
350 | self._flags = self._flags & ~fpb.FPB_EXCLUSIVE_FOLD | |
351 | self._flags = self._flags | fpb.FPB_COLLAPSE_TO_BOTTOM | |
352 | else: | |
353 | self._flags = self._flags & ~fpb.FPB_COLLAPSE_TO_BOTTOM | |
354 | ||
355 | self.ReCreateFoldPanel(self._flags) | |
356 | ||
357 | ||
358 | def OnCreateNormalStyle(self, event): | |
359 | ||
360 | # recreate with style where only one panel at the time is | |
361 | # allowed to be opened | |
362 | ||
363 | if event.IsChecked(): | |
364 | self.GetMenuBar().Check(self._bottomstyle, False) | |
365 | self.GetMenuBar().Check(self._exclusivestyle, False) | |
366 | self._flags = self._flags & ~fpb.FPB_EXCLUSIVE_FOLD | |
367 | self._flags = self._flags & ~fpb.FPB_COLLAPSE_TO_BOTTOM | |
368 | self._flags = self._flags | fpb.FPB_SINGLE_FOLD | |
369 | else: | |
370 | self._flags = self._flags & ~fpb.FPB_SINGLE_FOLD | |
371 | ||
372 | self.ReCreateFoldPanel(self._flags) | |
373 | ||
374 | ||
375 | def OnCreateExclusiveStyle(self, event): | |
376 | ||
377 | # recreate with style where only one panel at the time is | |
378 | # allowed to be opened and the others are collapsed to bottom | |
379 | ||
380 | if event.IsChecked(): | |
381 | self.GetMenuBar().Check(self._singlestyle, False) | |
382 | self.GetMenuBar().Check(self._bottomstyle, False) | |
383 | self._flags = self._flags & ~fpb.FPB_SINGLE_FOLD | |
384 | self._flags = self._flags & ~fpb.FPB_COLLAPSE_TO_BOTTOM | |
385 | self._flags = self._flags | fpb.FPB_EXCLUSIVE_FOLD | |
386 | else: | |
387 | self._flags = self._flags & ~fpb.FPB_EXCLUSIVE_FOLD | |
388 | ||
389 | self.ReCreateFoldPanel(self._flags) | |
390 | ||
391 | ||
392 | def OnCollapseMe(self, event): | |
393 | ||
394 | for i in range(0, self._pnl.GetCount()): | |
395 | item = self._pnl.GetFoldPanel(i) | |
396 | self._pnl.Collapse(item) | |
397 | ||
398 | ||
399 | def OnExpandMe(self, event): | |
400 | ||
401 | col1 = wx.Colour(self._rslider1.GetValue(), self._gslider1.GetValue(), | |
402 | self._bslider1.GetValue()) | |
403 | col2 = wx.Colour(self._rslider2.GetValue(), self._gslider2.GetValue(), | |
404 | self._bslider2.GetValue()) | |
405 | ||
406 | style = fpb.CaptionBarStyle() | |
407 | ||
408 | style.SetFirstColour(col1) | |
409 | style.SetSecondColour(col2) | |
410 | ||
411 | counter = 0 | |
412 | for items in self.radiocontrols: | |
413 | if items.GetValue(): | |
414 | break | |
415 | counter = counter + 1 | |
416 | ||
417 | if counter == 0: | |
418 | mystyle = fpb.CAPTIONBAR_GRADIENT_V | |
419 | elif counter == 1: | |
420 | mystyle = fpb.CAPTIONBAR_GRADIENT_H | |
421 | elif counter == 2: | |
422 | mystyle = fpb.CAPTIONBAR_SINGLE | |
423 | elif counter == 3: | |
424 | mystyle = fpb.CAPTIONBAR_RECTANGLE | |
425 | else: | |
426 | mystyle = fpb.CAPTIONBAR_FILLED_RECTANGLE | |
427 | ||
428 | style.SetCaptionStyle(mystyle) | |
429 | self._pnl.ApplyCaptionStyleAll(style) | |
430 | ||
431 | ||
432 | def OnSlideColour(self, event): | |
433 | ||
434 | col1 = wx.Colour(self._rslider1.GetValue(), self._gslider1.GetValue(), | |
435 | self._bslider1.GetValue()) | |
436 | col2 = wx.Colour(self._rslider2.GetValue(), self._gslider2.GetValue(), | |
437 | self._bslider2.GetValue()) | |
438 | ||
439 | style = fpb.CaptionBarStyle() | |
440 | ||
441 | counter = 0 | |
442 | for items in self.radiocontrols: | |
443 | if items.GetValue(): | |
444 | break | |
445 | ||
446 | counter = counter + 1 | |
447 | ||
448 | if counter == 0: | |
449 | mystyle = fpb.CAPTIONBAR_GRADIENT_V | |
450 | elif counter == 1: | |
451 | mystyle = fpb.CAPTIONBAR_GRADIENT_H | |
452 | elif counter == 2: | |
453 | mystyle = fpb.CAPTIONBAR_SINGLE | |
454 | elif counter == 3: | |
455 | mystyle = fpb.CAPTIONBAR_RECTANGLE | |
456 | else: | |
457 | mystyle = fpb.CAPTIONBAR_FILLED_RECTANGLE | |
458 | ||
459 | style.SetFirstColour(col1) | |
460 | style.SetSecondColour(col2) | |
461 | style.SetCaptionStyle(mystyle) | |
462 | ||
463 | item = self._pnl.GetFoldPanel(0) | |
464 | self._pnl.ApplyCaptionStyle(item, style) | |
465 | ||
466 | ||
467 | def OnStyleChange(self, event): | |
468 | ||
469 | style = fpb.CaptionBarStyle() | |
470 | ||
471 | eventid = event.GetId() | |
472 | ||
473 | if eventid == self.ID_USE_HGRADIENT: | |
474 | style.SetCaptionStyle(fpb.CAPTIONBAR_GRADIENT_H) | |
475 | ||
476 | elif eventid == self.ID_USE_VGRADIENT: | |
477 | style.SetCaptionStyle(fpb.CAPTIONBAR_GRADIENT_V) | |
478 | ||
479 | elif eventid == self.ID_USE_SINGLE: | |
480 | style.SetCaptionStyle(fpb.CAPTIONBAR_SINGLE) | |
481 | ||
482 | elif eventid == self.ID_USE_RECTANGLE: | |
483 | style.SetCaptionStyle(fpb.CAPTIONBAR_RECTANGLE) | |
484 | ||
485 | elif eventid == self.ID_USE_FILLED_RECTANGLE: | |
486 | style.SetCaptionStyle(fpb.CAPTIONBAR_FILLED_RECTANGLE) | |
487 | ||
488 | else: | |
489 | raise "ERROR: Undefined Style Selected For CaptionBar: " + repr(eventid) | |
490 | ||
491 | col1 = wx.Colour(self._rslider1.GetValue(), self._gslider1.GetValue(), | |
492 | self._bslider1.GetValue()) | |
493 | col2 = wx.Colour(self._rslider2.GetValue(), self._gslider2.GetValue(), | |
494 | self._bslider2.GetValue()) | |
495 | ||
496 | style.SetFirstColour(col1) | |
497 | style.SetSecondColour(col2) | |
498 | ||
499 | if self._single.GetValue(): | |
500 | item = self._pnl.GetFoldPanel(1) | |
501 | self._pnl.ApplyCaptionStyle(item, style) | |
502 | else: | |
503 | self._pnl.ApplyCaptionStyleAll(style) | |
504 | ||
505 | ||
506 | def CreateMenuBar(self, with_window=False): | |
507 | ||
508 | # Make a menubar | |
509 | file_menu = wx.Menu() | |
510 | ||
511 | FPBTEST_QUIT = wx.NewId() | |
512 | FPBTEST_REFRESH = wx.NewId() | |
513 | FPB_BOTTOM_FOLD = wx.NewId() | |
514 | FPB_SINGLE_FOLD = wx.NewId() | |
515 | FPB_EXCLUSIVE_FOLD = wx.NewId() | |
516 | FPBTEST_TOGGLE_WINDOW = wx.NewId() | |
517 | FPBTEST_ABOUT = wx.NewId() | |
518 | ||
519 | file_menu.Append(FPBTEST_QUIT, "&Exit") | |
520 | ||
521 | option_menu = None | |
522 | ||
523 | if with_window: | |
524 | # Dummy option | |
525 | option_menu = wx.Menu() | |
526 | option_menu.Append(FPBTEST_REFRESH, "&Refresh picture") | |
527 | ||
528 | # make fold panel menu | |
529 | ||
530 | fpb_menu = wx.Menu() | |
531 | fpb_menu.AppendCheckItem(FPB_BOTTOM_FOLD, "Create with &fpb.FPB_COLLAPSE_TO_BOTTOM") | |
532 | ||
533 | # Now Implemented! | |
534 | fpb_menu.AppendCheckItem(FPB_SINGLE_FOLD, "Create with &fpb.FPB_SINGLE_FOLD") | |
535 | ||
536 | # Now Implemented! | |
537 | fpb_menu.AppendCheckItem(FPB_EXCLUSIVE_FOLD, "Create with &fpb.FPB_EXCLUSIVE_FOLD") | |
538 | ||
539 | fpb_menu.AppendSeparator() | |
540 | fpb_menu.Append(FPBTEST_TOGGLE_WINDOW, "&Toggle FoldPanelBar") | |
541 | ||
542 | help_menu = wx.Menu() | |
543 | help_menu.Append(FPBTEST_ABOUT, "&About") | |
544 | ||
545 | menu_bar = wx.MenuBar() | |
546 | ||
547 | menu_bar.Append(file_menu, "&File") | |
548 | menu_bar.Append(fpb_menu, "&FoldPanel") | |
549 | ||
550 | if option_menu: | |
551 | menu_bar.Append(option_menu, "&Options") | |
552 | ||
553 | menu_bar.Append(help_menu, "&Help") | |
554 | ||
555 | self.Bind(wx.EVT_MENU, self.OnAbout, id=FPBTEST_ABOUT) | |
556 | self.Bind(wx.EVT_MENU, self.OnQuit, id=FPBTEST_QUIT) | |
557 | self.Bind(wx.EVT_MENU, self.OnToggleWindow, id=FPBTEST_TOGGLE_WINDOW) | |
558 | self.Bind(wx.EVT_MENU, self.OnCreateBottomStyle, id=FPB_BOTTOM_FOLD) | |
559 | self.Bind(wx.EVT_MENU, self.OnCreateNormalStyle, id=FPB_SINGLE_FOLD) | |
560 | self.Bind(wx.EVT_MENU, self.OnCreateExclusiveStyle, id=FPB_EXCLUSIVE_FOLD) | |
561 | ||
562 | self._bottomstyle = FPB_BOTTOM_FOLD | |
563 | self._singlestyle = FPB_SINGLE_FOLD | |
564 | self._exclusivestyle = FPB_EXCLUSIVE_FOLD | |
565 | ||
566 | return menu_bar | |
567 | ||
568 | ||
569 | # ---------------------------------------------------------------------------- | |
570 | # Collapsed Demo Implementation | |
571 | # ---------------------------------------------------------------------------- | |
572 | ||
573 | class FoldTestPanel(wx.Panel): | |
574 | ||
575 | def __init__(self, parent, id, pos=wx.DefaultPosition, size=wx.DefaultSize, | |
576 | style=wx.NO_BORDER | wx.TAB_TRAVERSAL): | |
577 | ||
578 | wx.Panel.__init__(self, parent, id, pos, size, style) | |
579 | ||
580 | self.CreateControls() | |
581 | self.GetSizer().Fit(self) | |
582 | self.GetSizer().SetSizeHints(self) | |
583 | self.GetSizer().Layout() | |
584 | ||
585 | self.Bind(fpb.EVT_CAPTIONBAR, self.OnPressCaption) | |
586 | ||
587 | ||
588 | def OnPressCaption(self, event): | |
589 | event.Skip() | |
590 | ||
591 | def CreateControls(self): | |
592 | ||
593 | sizer = wx.BoxSizer(wx.VERTICAL) | |
594 | self.SetSizer(sizer) | |
595 | ||
596 | subpanel = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, | |
597 | wx.NO_BORDER | wx.TAB_TRAVERSAL) | |
598 | sizer.Add(subpanel, 1, wx.GROW | wx.ADJUST_MINSIZE, 5) | |
599 | ||
600 | subsizer = wx.BoxSizer(wx.VERTICAL) | |
601 | subpanel.SetSizer(subsizer) | |
602 | itemstrings = ["One", "Two", "Three"] | |
603 | ||
604 | item5 = wx.Choice(subpanel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, | |
605 | itemstrings, 0) | |
606 | ||
607 | subsizer.Add(item5, 0, wx.GROW | wx.ALL, 5) | |
608 | ||
609 | item6 = wx.TextCtrl(subpanel, wx.ID_ANY, "", wx.DefaultPosition, wx.DefaultSize, | |
610 | wx.TE_MULTILINE) | |
611 | subsizer.Add(item6, 1, wx.GROW | wx.ALL, 5) | |
612 | ||
613 | item7 = wx.RadioButton(subpanel, wx.ID_ANY, "I Like This", wx.DefaultPosition, | |
614 | wx.DefaultSize, 0) | |
615 | item7.SetValue(True) | |
616 | subsizer.Add(item7, 0, wx.ALIGN_LEFT | wx.ALL, 5) | |
617 | ||
618 | item8 = wx.RadioButton(subpanel, wx.ID_ANY, "I Hate It", wx.DefaultPosition, | |
619 | wx.DefaultSize, 0) | |
620 | item8.SetValue(False) | |
621 | subsizer.Add(item8, 0, wx.ALIGN_LEFT | wx.ALL, 5) | |
622 | ||
623 | ||
624 | # ---------------------------------------------------------------------------- | |
625 | ||
626 | class Collapsed(wx.Frame): | |
627 | ||
628 | def __init__(self, parent, id=wx.ID_ANY, title="", pos=wx.DefaultPosition, | |
629 | size=(400,300), style=wx.DEFAULT_FRAME_STYLE): | |
630 | ||
631 | wx.Frame.__init__(self, parent, id, title, pos, size, style) | |
632 | ||
633 | self.SetIcon(GetMondrianIcon()) | |
634 | self.SetMenuBar(self.CreateMenuBar()) | |
635 | ||
636 | self.statusbar = self.CreateStatusBar(2, wx.ST_SIZEGRIP) | |
637 | self.statusbar.SetStatusWidths([-4, -3]) | |
638 | self.statusbar.SetStatusText("Andrea Gavana @ 23 Mar 2005", 0) | |
639 | self.statusbar.SetStatusText("Welcome to wxPython!", 1) | |
640 | ||
641 | self.CreateFoldBar() | |
642 | ||
643 | ||
644 | def CreateFoldBar(self, vertical=True): | |
645 | ||
646 | if vertical: | |
647 | self.SetSize((500,600)) | |
648 | else: | |
649 | self.SetSize((700,300)) | |
650 | ||
651 | newstyle = (vertical and [fpb.FPB_VERTICAL] or [fpb.FPB_HORIZONTAL])[0] | |
652 | ||
653 | bar = fpb.FoldPanelBar(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, | |
654 | fpb.FPB_DEFAULT_STYLE | newstyle, fpb.FPB_COLLAPSE_TO_BOTTOM) | |
655 | ||
656 | item = bar.AddFoldPanel("Test me", collapsed=False) | |
657 | button1 = wx.Button(item, wx.ID_ANY, "Collapse Me") | |
658 | button1.Bind(wx.EVT_BUTTON, self.OnCollapseMe) | |
659 | ||
660 | bar.AddFoldPanelWindow(item, button1, fpb.FPB_ALIGN_LEFT) | |
661 | ||
662 | item = bar.AddFoldPanel("Test me too!", collapsed=True) | |
663 | ||
664 | button2 = wx.Button(item, wx.ID_ANY, "Expand First One") | |
665 | button2.Bind(wx.EVT_BUTTON, self.OnExpandMe) | |
666 | ||
667 | bar.AddFoldPanelWindow(item, button2) | |
668 | bar.AddFoldPanelSeparator(item) | |
669 | ||
670 | newfoldpanel = FoldTestPanel(item, wx.ID_ANY) | |
671 | bar.AddFoldPanelWindow(item, newfoldpanel) | |
672 | ||
673 | bar.AddFoldPanelSeparator(item) | |
674 | ||
675 | bar.AddFoldPanelWindow(item, wx.TextCtrl(item, wx.ID_ANY, "Comment"), | |
676 | fpb.FPB_ALIGN_LEFT, fpb.FPB_DEFAULT_SPACING, 20) | |
677 | ||
678 | item = bar.AddFoldPanel("Some Opinions ...", collapsed=False) | |
679 | bar.AddFoldPanelWindow(item, wx.CheckBox(item, wx.ID_ANY, "I Like This")) | |
680 | ||
681 | if vertical: | |
682 | # do not add this for horizontal for better presentation | |
683 | bar.AddFoldPanelWindow(item, wx.CheckBox(item, wx.ID_ANY, "And also this")) | |
684 | bar.AddFoldPanelWindow(item, wx.CheckBox(item, wx.ID_ANY, "And gimme this too")) | |
685 | ||
686 | bar.AddFoldPanelSeparator(item) | |
687 | ||
688 | bar.AddFoldPanelWindow(item, wx.CheckBox(item, wx.ID_ANY, "Check this too if you like")) | |
689 | ||
690 | if vertical: | |
691 | # do not add this for horizontal for better presentation | |
692 | bar.AddFoldPanelWindow(item, wx.CheckBox(item, wx.ID_ANY, "What about this")) | |
693 | ||
694 | item = bar.AddFoldPanel("Choose one ...", collapsed=False) | |
695 | bar.AddFoldPanelWindow(item, wx.StaticText(item, wx.ID_ANY, "Enter your comment")) | |
696 | bar.AddFoldPanelWindow(item, wx.TextCtrl(item, wx.ID_ANY, "Comment"), | |
697 | fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 20) | |
698 | ||
699 | if hasattr(self, "pnl"): | |
700 | self.pnl.Destroy() | |
701 | ||
702 | self.pnl = bar | |
703 | ||
704 | size = self.GetClientSize() | |
705 | self.pnl.SetDimensions(0, 0, size.GetWidth(), size.GetHeight()) | |
706 | ||
707 | ||
708 | def CreateMenuBar(self): | |
709 | ||
710 | FoldPanelBarTest_Quit = wx.NewId() | |
711 | FoldPanelBarTest_About = wx.NewId() | |
712 | FoldPanelBarTest_Horizontal = wx.NewId() | |
713 | FoldPanelBarTest_Vertical = wx.NewId() | |
714 | ||
715 | menuFile = wx.Menu() | |
716 | menuFile.Append(FoldPanelBarTest_Horizontal, "&Horizontal\tAlt-H") | |
717 | menuFile.Append(FoldPanelBarTest_Vertical, "&Vertical\tAlt-V") | |
718 | menuFile.AppendSeparator() | |
719 | menuFile.Append(FoldPanelBarTest_Quit, "E&xit\tAlt-X", "Quit This Program") | |
720 | ||
721 | helpMenu = wx.Menu() | |
722 | helpMenu.Append(FoldPanelBarTest_About, "&About...\tF1", "Show About Dialog") | |
723 | ||
724 | self.FoldPanelBarTest_Vertical = FoldPanelBarTest_Vertical | |
725 | self.FoldPanelBarTest_Horizontal = FoldPanelBarTest_Horizontal | |
726 | ||
727 | self.Bind(wx.EVT_MENU, self.OnQuit, id=FoldPanelBarTest_Quit) | |
728 | self.Bind(wx.EVT_MENU, self.OnAbout, id=FoldPanelBarTest_About) | |
729 | self.Bind(wx.EVT_MENU, self.OnOrientation, id=FoldPanelBarTest_Horizontal) | |
730 | self.Bind(wx.EVT_MENU, self.OnOrientation, id=FoldPanelBarTest_Vertical) | |
731 | ||
732 | value = wx.MenuBar() | |
733 | value.Append(menuFile, "&File") | |
734 | value.Append(helpMenu, "&Help") | |
735 | ||
736 | return value | |
737 | ||
738 | ||
739 | def OnOrientation(self, event): | |
740 | self.CreateFoldBar(event.GetId() == self.FoldPanelBarTest_Vertical) | |
741 | ||
742 | ||
743 | def OnQuit(self, event): | |
744 | # True is to force the frame to close | |
745 | self.Close(True) | |
746 | ||
747 | ||
748 | def OnAbout(self, event): | |
749 | ||
750 | msg = "This is the about dialog of the FoldPanelBarTest application.\n\n" + \ | |
751 | "Welcome To wxPython " + wx.VERSION_STRING + "!!" | |
752 | dlg = wx.MessageDialog(self, msg, "About FoldPanelBarTest", | |
753 | wx.OK | wx.ICON_INFORMATION) | |
754 | dlg.ShowModal() | |
755 | dlg.Destroy() | |
756 | ||
757 | ||
758 | def OnCollapseMe(self, event): | |
759 | ||
760 | item = self.pnl.GetFoldPanel(0) | |
761 | self.pnl.Collapse(item) | |
762 | ||
763 | def OnExpandMe(self, event): | |
764 | ||
765 | self.pnl.Expand(self.pnl.GetFoldPanel(0)) | |
766 | self.pnl.Collapse(self.pnl.GetFoldPanel(1)) | |
767 | ||
768 | ||
769 | ||
770 | # ---------------------------------------------------------------------------- | |
771 | # NotCollapsed Implementation | |
772 | # ---------------------------------------------------------------------------- | |
773 | ||
774 | class NotCollapsed(wx.Frame): | |
775 | def __init__(self, parent, id=wx.ID_ANY, title="", pos=wx.DefaultPosition, | |
776 | size=(400,300), style=wx.DEFAULT_FRAME_STYLE): | |
777 | ||
778 | wx.Frame.__init__(self, parent, id, title, pos, size, style) | |
779 | ||
780 | self.SetIcon(GetMondrianIcon()) | |
781 | self.SetMenuBar(self.CreateMenuBar()) | |
782 | ||
783 | self.statusbar = self.CreateStatusBar(2, wx.ST_SIZEGRIP) | |
784 | self.statusbar.SetStatusWidths([-4, -3]) | |
785 | self.statusbar.SetStatusText("Andrea Gavana @ 23 Mar 2005", 0) | |
786 | self.statusbar.SetStatusText("Welcome to wxPython!", 1) | |
787 | ||
788 | pnl = fpb.FoldPanelBar(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, | |
789 | fpb.FPB_DEFAULT_STYLE | fpb.FPB_VERTICAL) | |
790 | ||
791 | item = pnl.AddFoldPanel("Test Me", collapsed=False) | |
792 | ||
793 | button1 = wx.Button(item, wx.ID_ANY, "Collapse Me") | |
794 | ||
795 | pnl.AddFoldPanelWindow(item, button1, fpb.FPB_ALIGN_LEFT) | |
796 | pnl.AddFoldPanelSeparator(item) | |
797 | ||
798 | button1.Bind(wx.EVT_BUTTON, self.OnCollapseMe) | |
799 | ||
800 | item = pnl.AddFoldPanel("Test Me Too!", collapsed=True) | |
801 | button2 = wx.Button(item, wx.ID_ANY, "Expand First One") | |
802 | pnl.AddFoldPanelWindow(item, button2, fpb.FPB_ALIGN_LEFT) | |
803 | pnl.AddFoldPanelSeparator(item) | |
804 | ||
805 | button2.Bind(wx.EVT_BUTTON, self.OnExpandMe) | |
806 | ||
807 | newfoldpanel = FoldTestPanel(item, wx.ID_ANY) | |
808 | pnl.AddFoldPanelWindow(item, newfoldpanel) | |
809 | ||
810 | pnl.AddFoldPanelSeparator(item) | |
811 | ||
812 | pnl.AddFoldPanelWindow(item, wx.TextCtrl(item, wx.ID_ANY, "Comment"), | |
813 | fpb.FPB_ALIGN_LEFT, fpb.FPB_DEFAULT_SPACING, 20) | |
814 | ||
815 | item = pnl.AddFoldPanel("Some Opinions ...", collapsed=False) | |
816 | pnl.AddFoldPanelWindow(item, wx.CheckBox(item, wx.ID_ANY, "I Like This")) | |
817 | pnl.AddFoldPanelWindow(item, wx.CheckBox(item, wx.ID_ANY, "And Also This")) | |
818 | pnl.AddFoldPanelWindow(item, wx.CheckBox(item, wx.ID_ANY, "And Gimme This Too")) | |
819 | ||
820 | pnl.AddFoldPanelSeparator(item) | |
821 | ||
822 | pnl.AddFoldPanelWindow(item, wx.CheckBox(item, wx.ID_ANY, "Check This Too If You Like")) | |
823 | pnl.AddFoldPanelWindow(item, wx.CheckBox(item, wx.ID_ANY, "What About This")) | |
824 | ||
825 | item = pnl.AddFoldPanel("Choose One ...", collapsed=False) | |
826 | pnl.AddFoldPanelWindow(item, wx.StaticText(item, wx.ID_ANY, "Enter Your Comment")) | |
827 | pnl.AddFoldPanelWindow(item, wx.TextCtrl(item, wx.ID_ANY, "Comment"), | |
828 | fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 20, 20) | |
829 | self.pnl = pnl | |
830 | ||
831 | ||
832 | def CreateMenuBar(self): | |
833 | ||
834 | FoldPanelBarTest_Quit = wx.NewId() | |
835 | FoldPanelBarTest_About = wx.NewId() | |
836 | ||
837 | menuFile = wx.Menu() | |
838 | menuFile.Append(FoldPanelBarTest_Quit, "E&xit\tAlt-X", "Quit This Program") | |
839 | ||
840 | helpMenu = wx.Menu() | |
841 | helpMenu.Append(FoldPanelBarTest_About, "&About...\tF1", "Show About Dialog") | |
842 | ||
843 | self.Bind(wx.EVT_MENU, self.OnQuit, id=FoldPanelBarTest_Quit) | |
844 | self.Bind(wx.EVT_MENU, self.OnAbout, id=FoldPanelBarTest_About) | |
845 | ||
846 | value = wx.MenuBar() | |
847 | value.Append(menuFile, "&File") | |
848 | value.Append(helpMenu, "&Help") | |
849 | ||
850 | return value | |
851 | ||
852 | ||
853 | # Event Handlers | |
854 | ||
855 | def OnQuit(self, event): | |
856 | ||
857 | # True is to force the frame to close | |
858 | self.Close(True) | |
859 | ||
860 | ||
861 | def OnAbout(self, event): | |
862 | ||
863 | msg = "This is the about dialog of the FoldPanelBarTest application.\n\n" + \ | |
864 | "Welcome To wxPython " + wx.VERSION_STRING + "!!" | |
865 | dlg = wx.MessageDialog(self, msg, "About FoldPanelBarTest", | |
866 | wx.OK | wx.ICON_INFORMATION) | |
867 | dlg.ShowModal() | |
868 | dlg.Destroy() | |
869 | ||
870 | ||
871 | def OnCollapseMe(self, event): | |
872 | ||
873 | item = self.pnl.GetFoldPanel(0) | |
874 | self.pnl.Collapse(item) | |
875 | ||
876 | def OnExpandMe(self, event): | |
877 | ||
878 | self.pnl.Expand(self.pnl.GetFoldPanel(0)) | |
879 | self.pnl.Collapse(self.pnl.GetFoldPanel(1)) | |
880 | ||
881 | ||
882 | #--------------------------------------------------------------------------- | |
883 | #--------------------------------------------------------------------------- | |
884 | ||
885 | class TestPanel(wx.Panel): | |
886 | def __init__(self, parent, log): | |
887 | self.log = log | |
888 | wx.Panel.__init__(self, parent, -1) | |
889 | ||
890 | vsizer = wx.BoxSizer(wx.VERTICAL) | |
891 | b = wx.Button(self, -1, "FoldPanelBar Extended Demo") | |
892 | vsizer.Add(b, 0, wx.ALL, 5) | |
893 | self.Bind(wx.EVT_BUTTON, self.OnButton1, b) | |
894 | ||
895 | b = wx.Button(self, -1, "FoldPanelBar Collapsed Demo") | |
896 | vsizer.Add(b, 0, wx.ALL, 5) | |
897 | self.Bind(wx.EVT_BUTTON, self.OnButton2, b) | |
898 | ||
899 | b = wx.Button(self, -1, "FoldPanelBar NotCollapsed Demo") | |
900 | vsizer.Add(b, 0, wx.ALL, 5) | |
901 | self.Bind(wx.EVT_BUTTON, self.OnButton3, b) | |
902 | ||
903 | bdr = wx.BoxSizer() | |
904 | bdr.Add(vsizer, 0, wx.ALL, 50) | |
905 | self.SetSizer(bdr) | |
906 | ||
907 | def OnButton1(self, evt): | |
908 | frame = Extended(self, title="FoldPanelBar Extended Demo") | |
909 | frame.Show() | |
910 | ||
911 | def OnButton2(self, evt): | |
912 | frame = Collapsed(self, title="FoldPanelBar Collapsed Demo") | |
913 | frame.Show() | |
914 | ||
915 | def OnButton3(self, evt): | |
916 | frame = NotCollapsed(self, title="FoldPanelBar NotCollapsed Demo") | |
917 | frame.Show() | |
918 | ||
919 | ||
920 | #--------------------------------------------------------------------------- | |
921 | ||
922 | ||
923 | def runTest(frame, nb, log): | |
924 | win = TestPanel(nb, log) | |
925 | return win | |
926 | ||
927 | ||
928 | #--------------------------------------------------------------------------- | |
929 | ||
930 | ||
931 | overview = fpb.__doc__ | |
932 | ||
933 | ||
934 | if __name__ == '__main__': | |
935 | import sys,os | |
936 | import run | |
937 | run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:]) | |
938 |