8 ID_CreateTree
= wx
.NewId()
9 ID_CreateGrid
= wx
.NewId()
10 ID_CreateText
= wx
.NewId()
11 ID_CreateHTML
= wx
.NewId()
12 ID_CreateSizeReport
= wx
.NewId()
13 ID_GridContent
= wx
.NewId()
14 ID_TextContent
= wx
.NewId()
15 ID_TreeContent
= wx
.NewId()
16 ID_HTMLContent
= wx
.NewId()
17 ID_SizeReportContent
= wx
.NewId()
18 ID_CreatePerspective
= wx
.NewId()
19 ID_CopyPerspective
= wx
.NewId()
21 ID_TransparentHint
= wx
.NewId()
22 ID_VenetianBlindsHint
= wx
.NewId()
23 ID_RectangleHint
= wx
.NewId()
24 ID_NoHint
= wx
.NewId()
25 ID_HintFade
= wx
.NewId()
26 ID_AllowFloating
= wx
.NewId()
27 ID_NoVenetianFade
= wx
.NewId()
28 ID_TransparentDrag
= wx
.NewId()
29 ID_AllowActivePane
= wx
.NewId()
30 ID_NoGradient
= wx
.NewId()
31 ID_VerticalGradient
= wx
.NewId()
32 ID_HorizontalGradient
= wx
.NewId()
34 ID_Settings
= wx
.NewId()
36 ID_FirstPerspective
= ID_CreatePerspective
+1000
40 #----------------------------------------------------------------------
41 def GetMondrianData():
43 '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\
44 \x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x00qID\
45 ATX\x85\xed\xd6;\n\x800\x10E\xd1{\xc5\x8d\xb9r\x97\x16\x0b\xad$\x8a\x82:\x16\
46 o\xda\x84pB2\x1f\x81Fa\x8c\x9c\x08\x04Z{\xcf\xa72\xbcv\xfa\xc5\x08 \x80r\x80\
47 \xfc\xa2\x0e\x1c\xe4\xba\xfaX\x1d\xd0\xde]S\x07\x02\xd8>\xe1wa-`\x9fQ\xe9\
48 \x86\x01\x04\x10\x00\\(Dk\x1b-\x04\xdc\x1d\x07\x14\x98;\x0bS\x7f\x7f\xf9\x13\
49 \x04\x10@\xf9X\xbe\x00\xc9 \x14K\xc1<={\x00\x00\x00\x00IEND\xaeB`\x82'
52 def GetMondrianBitmap():
53 return wx
.BitmapFromImage(GetMondrianImage())
56 def GetMondrianImage():
57 stream
= cStringIO
.StringIO(GetMondrianData())
58 return wx
.ImageFromStream(stream
)
61 def GetMondrianIcon():
63 icon
.CopyFromBitmap(GetMondrianBitmap())
67 class PyAUIFrame(wx
.Frame
):
69 def __init__(self
, parent
, id=-1, title
="", pos
=wx
.DefaultPosition
,
70 size
=wx
.DefaultSize
, style
=wx
.DEFAULT_FRAME_STYLE |
74 wx
.Frame
.__init
__(self
, parent
, id, title
, pos
, size
, style
)
76 # tell FrameManager to manage this frame
77 self
._mgr
= wx
.aui
.AuiManager()
78 self
._mgr
.SetManagedWindow(self
)
80 self
._perspectives
= []
84 self
.SetIcon(GetMondrianIcon())
90 file_menu
.Append(wx
.ID_EXIT
, "Exit")
93 view_menu
.Append(ID_CreateText
, "Create Text Control")
94 view_menu
.Append(ID_CreateHTML
, "Create HTML Control")
95 view_menu
.Append(ID_CreateTree
, "Create Tree")
96 view_menu
.Append(ID_CreateGrid
, "Create Grid")
97 view_menu
.Append(ID_CreateSizeReport
, "Create Size Reporter")
98 view_menu
.AppendSeparator()
99 view_menu
.Append(ID_GridContent
, "Use a Grid for the Content Pane")
100 view_menu
.Append(ID_TextContent
, "Use a Text Control for the Content Pane")
101 view_menu
.Append(ID_HTMLContent
, "Use an HTML Control for the Content Pane")
102 view_menu
.Append(ID_TreeContent
, "Use a Tree Control for the Content Pane")
103 view_menu
.Append(ID_SizeReportContent
, "Use a Size Reporter for the Content Pane")
105 options_menu
= wx
.Menu()
106 options_menu
.AppendRadioItem(ID_TransparentHint
, "Transparent Hint")
107 options_menu
.AppendRadioItem(ID_VenetianBlindsHint
, "Venetian Blinds Hint")
108 options_menu
.AppendRadioItem(ID_RectangleHint
, "Rectangle Hint")
109 options_menu
.AppendRadioItem(ID_NoHint
, "No Hint")
110 options_menu
.AppendSeparator();
111 options_menu
.AppendCheckItem(ID_HintFade
, "Hint Fade-in")
112 options_menu
.AppendCheckItem(ID_AllowFloating
, "Allow Floating")
113 options_menu
.AppendCheckItem(ID_NoVenetianFade
, "Disable Venetian Blinds Hint Fade-in")
114 options_menu
.AppendCheckItem(ID_TransparentDrag
, "Transparent Drag")
115 options_menu
.AppendCheckItem(ID_AllowActivePane
, "Allow Active Pane")
116 options_menu
.AppendSeparator();
117 options_menu
.AppendRadioItem(ID_NoGradient
, "No Caption Gradient")
118 options_menu
.AppendRadioItem(ID_VerticalGradient
, "Vertical Caption Gradient")
119 options_menu
.AppendRadioItem(ID_HorizontalGradient
, "Horizontal Caption Gradient")
120 options_menu
.AppendSeparator();
121 options_menu
.Append(ID_Settings
, "Settings Pane")
123 self
._perspectives
_menu
= wx
.Menu()
124 self
._perspectives
_menu
.Append(ID_CreatePerspective
, "Create Perspective")
125 self
._perspectives
_menu
.Append(ID_CopyPerspective
, "Copy Perspective Data To Clipboard")
126 self
._perspectives
_menu
.AppendSeparator()
127 self
._perspectives
_menu
.Append(ID_FirstPerspective
+0, "Default Startup")
128 self
._perspectives
_menu
.Append(ID_FirstPerspective
+1, "All Panes")
129 self
._perspectives
_menu
.Append(ID_FirstPerspective
+2, "Vertical Toolbar")
131 help_menu
= wx
.Menu()
132 help_menu
.Append(ID_About
, "About...")
134 mb
.Append(file_menu
, "File")
135 mb
.Append(view_menu
, "View")
136 mb
.Append(self
._perspectives
_menu
, "Perspectives")
137 mb
.Append(options_menu
, "Options")
138 mb
.Append(help_menu
, "Help")
142 self
.statusbar
= self
.CreateStatusBar(2, wx
.ST_SIZEGRIP
)
143 self
.statusbar
.SetStatusWidths([-2, -3])
144 self
.statusbar
.SetStatusText("Ready", 0)
145 self
.statusbar
.SetStatusText("Welcome To wxPython!", 1)
147 # min size for the frame itself isn't completely done.
148 # see the end up FrameManager::Update() for the test
149 # code. For now, just hard code a frame minimum size
150 self
.SetMinSize(wx
.Size(400, 300))
152 # create some toolbars
153 tb1
= wx
.ToolBar(self
, -1, wx
.DefaultPosition
, wx
.DefaultSize
,
154 wx
.TB_FLAT | wx
.TB_NODIVIDER
)
155 tb1
.SetToolBitmapSize(wx
.Size(48,48))
156 tb1
.AddLabelTool(101, "Test", wx
.ArtProvider_GetBitmap(wx
.ART_ERROR
))
158 tb1
.AddLabelTool(102, "Test", wx
.ArtProvider_GetBitmap(wx
.ART_QUESTION
))
159 tb1
.AddLabelTool(103, "Test", wx
.ArtProvider_GetBitmap(wx
.ART_INFORMATION
))
160 tb1
.AddLabelTool(103, "Test", wx
.ArtProvider_GetBitmap(wx
.ART_WARNING
))
161 tb1
.AddLabelTool(103, "Test", wx
.ArtProvider_GetBitmap(wx
.ART_MISSING_IMAGE
))
164 tb2
= wx
.ToolBar(self
, -1, wx
.DefaultPosition
, wx
.DefaultSize
,
165 wx
.TB_FLAT | wx
.TB_NODIVIDER
)
166 tb2
.SetToolBitmapSize(wx
.Size(16,16))
167 tb2_bmp1
= wx
.ArtProvider_GetBitmap(wx
.ART_QUESTION
, wx
.ART_OTHER
, wx
.Size(16, 16))
168 tb2
.AddLabelTool(101, "Test", tb2_bmp1
)
169 tb2
.AddLabelTool(101, "Test", tb2_bmp1
)
170 tb2
.AddLabelTool(101, "Test", tb2_bmp1
)
171 tb2
.AddLabelTool(101, "Test", tb2_bmp1
)
173 tb2
.AddLabelTool(101, "Test", tb2_bmp1
)
174 tb2
.AddLabelTool(101, "Test", tb2_bmp1
)
176 tb2
.AddLabelTool(101, "Test", tb2_bmp1
)
177 tb2
.AddLabelTool(101, "Test", tb2_bmp1
)
178 tb2
.AddLabelTool(101, "Test", tb2_bmp1
)
179 tb2
.AddLabelTool(101, "Test", tb2_bmp1
)
182 tb3
= wx
.ToolBar(self
, -1, wx
.DefaultPosition
, wx
.DefaultSize
,
183 wx
.TB_FLAT | wx
.TB_NODIVIDER
)
184 tb3
.SetToolBitmapSize(wx
.Size(16,16))
185 tb3_bmp1
= wx
.ArtProvider_GetBitmap(wx
.ART_FOLDER
, wx
.ART_OTHER
, wx
.Size(16, 16))
186 tb3
.AddLabelTool(101, "Test", tb3_bmp1
)
187 tb3
.AddLabelTool(101, "Test", tb3_bmp1
)
188 tb3
.AddLabelTool(101, "Test", tb3_bmp1
)
189 tb3
.AddLabelTool(101, "Test", tb3_bmp1
)
191 tb3
.AddLabelTool(101, "Test", tb3_bmp1
)
192 tb3
.AddLabelTool(101, "Test", tb3_bmp1
)
195 tb4
= wx
.ToolBar(self
, -1, wx
.DefaultPosition
, wx
.DefaultSize
,
196 wx
.TB_FLAT | wx
.TB_NODIVIDER | wx
.TB_HORZ_TEXT
)
197 tb4
.SetToolBitmapSize(wx
.Size(16,16))
198 tb4_bmp1
= wx
.ArtProvider_GetBitmap(wx
.ART_NORMAL_FILE
, wx
.ART_OTHER
, wx
.Size(16, 16))
199 tb4
.AddLabelTool(101, "Item 1", tb4_bmp1
)
200 tb4
.AddLabelTool(101, "Item 2", tb4_bmp1
)
201 tb4
.AddLabelTool(101, "Item 3", tb4_bmp1
)
202 tb4
.AddLabelTool(101, "Item 4", tb4_bmp1
)
204 tb4
.AddLabelTool(101, "Item 5", tb4_bmp1
)
205 tb4
.AddLabelTool(101, "Item 6", tb4_bmp1
)
206 tb4
.AddLabelTool(101, "Item 7", tb4_bmp1
)
207 tb4
.AddLabelTool(101, "Item 8", tb4_bmp1
)
210 tb5
= wx
.ToolBar(self
, -1, wx
.DefaultPosition
, wx
.DefaultSize
,
211 wx
.TB_FLAT | wx
.TB_NODIVIDER | wx
.TB_VERTICAL
)
212 tb5
.SetToolBitmapSize(wx
.Size(48, 48))
213 tb5
.AddLabelTool(101, "Test", wx
.ArtProvider_GetBitmap(wx
.ART_ERROR
))
215 tb5
.AddLabelTool(102, "Test", wx
.ArtProvider_GetBitmap(wx
.ART_QUESTION
))
216 tb5
.AddLabelTool(103, "Test", wx
.ArtProvider_GetBitmap(wx
.ART_INFORMATION
))
217 tb5
.AddLabelTool(103, "Test", wx
.ArtProvider_GetBitmap(wx
.ART_WARNING
))
218 tb5
.AddLabelTool(103, "Test", wx
.ArtProvider_GetBitmap(wx
.ART_MISSING_IMAGE
))
221 # add a bunch of panes
222 self
._mgr
.AddPane(self
.CreateSizeReportCtrl(), wx
.aui
.AuiPaneInfo().
223 Name("test1").Caption("Pane Caption").Top().
224 CloseButton(True).MaximizeButton(True))
226 self
._mgr
.AddPane(self
.CreateSizeReportCtrl(), wx
.aui
.AuiPaneInfo().
227 Name("test2").Caption("Client Size Reporter").
228 Bottom().Position(1).CloseButton(True).MaximizeButton(True))
230 self
._mgr
.AddPane(self
.CreateSizeReportCtrl(), wx
.aui
.AuiPaneInfo().
231 Name("test3").Caption("Client Size Reporter").
232 Bottom().CloseButton(True).MaximizeButton(True))
234 self
._mgr
.AddPane(self
.CreateSizeReportCtrl(), wx
.aui
.AuiPaneInfo().
235 Name("test4").Caption("Pane Caption").
236 Left().CloseButton(True).MaximizeButton(True))
238 self
._mgr
.AddPane(self
.CreateSizeReportCtrl(), wx
.aui
.AuiPaneInfo().
239 Name("test5").Caption("Pane Caption").
240 Right().CloseButton(True).MaximizeButton(True))
242 self
._mgr
.AddPane(self
.CreateSizeReportCtrl(), wx
.aui
.AuiPaneInfo().
243 Name("test6").Caption("Client Size Reporter").
244 Right().Row(1).CloseButton(True).MaximizeButton(True))
246 self
._mgr
.AddPane(self
.CreateSizeReportCtrl(), wx
.aui
.AuiPaneInfo().
247 Name("test7").Caption("Client Size Reporter").
248 Left().Layer(1).CloseButton(True).MaximizeButton(True))
250 self
._mgr
.AddPane(self
.CreateTreeCtrl(), wx
.aui
.AuiPaneInfo().
251 Name("test8").Caption("Tree Pane").
252 Left().Layer(1).Position(1).CloseButton(True).MaximizeButton(True))
254 self
._mgr
.AddPane(self
.CreateSizeReportCtrl(), wx
.aui
.AuiPaneInfo().
255 Name("test9").Caption("Min Size 200x100").
256 BestSize(wx
.Size(200,100)).MinSize(wx
.Size(200,100)).
257 Bottom().Layer(1).CloseButton(True).MaximizeButton(True))
259 self
._mgr
.AddPane(self
.CreateTextCtrl(), wx
.aui
.AuiPaneInfo().
260 Name("test10").Caption("Text Pane").
261 Bottom().Layer(1).Position(1).CloseButton(True).MaximizeButton(True))
263 self
._mgr
.AddPane(self
.CreateSizeReportCtrl(), wx
.aui
.AuiPaneInfo().
264 Name("test11").Caption("Fixed Pane").
265 Bottom().Layer(1).Position(2).Fixed().CloseButton(True).MaximizeButton(True))
267 self
._mgr
.AddPane(SettingsPanel(self
, self
), wx
.aui
.AuiPaneInfo().
268 Name("settings").Caption("Dock Manager Settings").
269 Dockable(False).Float().Hide().CloseButton(True).MaximizeButton(True))
271 # create some center panes
273 self
._mgr
.AddPane(self
.CreateGrid(), wx
.aui
.AuiPaneInfo().Name("grid_content").
276 self
._mgr
.AddPane(self
.CreateTreeCtrl(), wx
.aui
.AuiPaneInfo().Name("tree_content").
279 self
._mgr
.AddPane(self
.CreateSizeReportCtrl(), wx
.aui
.AuiPaneInfo().Name("sizereport_content").
282 self
._mgr
.AddPane(self
.CreateTextCtrl(), wx
.aui
.AuiPaneInfo().Name("text_content").
285 self
._mgr
.AddPane(self
.CreateHTMLCtrl(), wx
.aui
.AuiPaneInfo().Name("html_content").
288 # add the toolbars to the manager
290 self
._mgr
.AddPane(tb1
, wx
.aui
.AuiPaneInfo().
291 Name("tb1").Caption("Big Toolbar").
293 LeftDockable(False).RightDockable(False))
295 self
._mgr
.AddPane(tb2
, wx
.aui
.AuiPaneInfo().
296 Name("tb2").Caption("Toolbar 2").
297 ToolbarPane().Top().Row(1).
298 LeftDockable(False).RightDockable(False))
300 self
._mgr
.AddPane(tb3
, wx
.aui
.AuiPaneInfo().
301 Name("tb3").Caption("Toolbar 3").
302 ToolbarPane().Top().Row(1).Position(1).
303 LeftDockable(False).RightDockable(False))
305 self
._mgr
.AddPane(tb4
, wx
.aui
.AuiPaneInfo().
306 Name("tb4").Caption("Sample Bookmark Toolbar").
307 ToolbarPane().Top().Row(2).
308 LeftDockable(False).RightDockable(False))
310 self
._mgr
.AddPane(tb5
, wx
.aui
.AuiPaneInfo().
311 Name("tbvert").Caption("Sample Vertical Toolbar").
312 ToolbarPane().Left().GripperTop().
313 TopDockable(False).BottomDockable(False))
315 self
._mgr
.AddPane(wx
.Button(self
, -1, "Test Button"),
316 wx
.aui
.AuiPaneInfo().Name("tb5").
317 ToolbarPane().Top().Row(2).Position(1).
318 LeftDockable(False).RightDockable(False))
320 # make some default perspectives
322 self
._mgr
.GetPane("tbvert").Hide()
324 perspective_all
= self
._mgr
.SavePerspective()
326 all_panes
= self
._mgr
.GetAllPanes()
328 for ii
in xrange(len(all_panes
)):
329 if not all_panes
[ii
].IsToolbar():
332 self
._mgr
.GetPane("tb1").Hide()
333 self
._mgr
.GetPane("tb5").Hide()
334 self
._mgr
.GetPane("test8").Show().Left().Layer(0).Row(0).Position(0)
335 self
._mgr
.GetPane("test10").Show().Bottom().Layer(0).Row(0).Position(0)
336 self
._mgr
.GetPane("html_content").Show()
338 perspective_default
= self
._mgr
.SavePerspective()
340 for ii
in xrange(len(all_panes
)):
341 if not all_panes
[ii
].IsToolbar():
344 self
._mgr
.GetPane("tb1").Hide()
345 self
._mgr
.GetPane("tb5").Hide()
346 self
._mgr
.GetPane("tbvert").Show()
347 self
._mgr
.GetPane("grid_content").Show()
348 self
._mgr
.GetPane("test8").Show().Left().Layer(0).Row(0).Position(0)
349 self
._mgr
.GetPane("test10").Show().Bottom().Layer(0).Row(0).Position(0)
350 self
._mgr
.GetPane("html_content").Show()
352 perspective_vert
= self
._mgr
.SavePerspective()
354 self
._perspectives
.append(perspective_default
)
355 self
._perspectives
.append(perspective_all
)
356 self
._perspectives
.append(perspective_vert
)
358 self
._mgr
.GetPane("tbvert").Hide()
359 self
._mgr
.GetPane("grid_content").Hide()
361 # "commit" all changes made to FrameManager
364 self
.Bind(wx
.EVT_ERASE_BACKGROUND
, self
.OnEraseBackground
)
365 self
.Bind(wx
.EVT_SIZE
, self
.OnSize
)
366 self
.Bind(wx
.EVT_CLOSE
, self
.OnClose
)
368 # Show How To Use The Closing Panes Event
369 self
.Bind(wx
.aui
.EVT_AUI_PANE_CLOSE
, self
.OnPaneClose
)
371 self
.Bind(wx
.EVT_MENU
, self
.OnCreateTree
, id=ID_CreateTree
)
372 self
.Bind(wx
.EVT_MENU
, self
.OnCreateGrid
, id=ID_CreateGrid
)
373 self
.Bind(wx
.EVT_MENU
, self
.OnCreateText
, id=ID_CreateText
)
374 self
.Bind(wx
.EVT_MENU
, self
.OnCreateHTML
, id=ID_CreateHTML
)
375 self
.Bind(wx
.EVT_MENU
, self
.OnCreateSizeReport
, id=ID_CreateSizeReport
)
376 self
.Bind(wx
.EVT_MENU
, self
.OnCreatePerspective
, id=ID_CreatePerspective
)
377 self
.Bind(wx
.EVT_MENU
, self
.OnCopyPerspective
, id=ID_CopyPerspective
)
379 self
.Bind(wx
.EVT_MENU
, self
.OnManagerFlag
, id=ID_AllowFloating
)
380 self
.Bind(wx
.EVT_MENU
, self
.OnManagerFlag
, id=ID_TransparentHint
)
381 self
.Bind(wx
.EVT_MENU
, self
.OnManagerFlag
, id=ID_VenetianBlindsHint
)
382 self
.Bind(wx
.EVT_MENU
, self
.OnManagerFlag
, id=ID_RectangleHint
)
383 self
.Bind(wx
.EVT_MENU
, self
.OnManagerFlag
, id=ID_NoHint
)
384 self
.Bind(wx
.EVT_MENU
, self
.OnManagerFlag
, id=ID_HintFade
)
385 self
.Bind(wx
.EVT_MENU
, self
.OnManagerFlag
, id=ID_NoVenetianFade
)
386 self
.Bind(wx
.EVT_MENU
, self
.OnManagerFlag
, id=ID_TransparentDrag
)
387 self
.Bind(wx
.EVT_MENU
, self
.OnManagerFlag
, id=ID_AllowActivePane
)
389 self
.Bind(wx
.EVT_MENU
, self
.OnGradient
, id=ID_NoGradient
)
390 self
.Bind(wx
.EVT_MENU
, self
.OnGradient
, id=ID_VerticalGradient
)
391 self
.Bind(wx
.EVT_MENU
, self
.OnGradient
, id=ID_HorizontalGradient
)
392 self
.Bind(wx
.EVT_MENU
, self
.OnSettings
, id=ID_Settings
)
393 self
.Bind(wx
.EVT_MENU
, self
.OnChangeContentPane
, id=ID_GridContent
)
394 self
.Bind(wx
.EVT_MENU
, self
.OnChangeContentPane
, id=ID_TreeContent
)
395 self
.Bind(wx
.EVT_MENU
, self
.OnChangeContentPane
, id=ID_TextContent
)
396 self
.Bind(wx
.EVT_MENU
, self
.OnChangeContentPane
, id=ID_SizeReportContent
)
397 self
.Bind(wx
.EVT_MENU
, self
.OnChangeContentPane
, id=ID_HTMLContent
)
398 self
.Bind(wx
.EVT_MENU
, self
.OnClose
, id=wx
.ID_EXIT
)
399 self
.Bind(wx
.EVT_MENU
, self
.OnAbout
, id=ID_About
)
401 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_TransparentHint
)
402 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_VenetianBlindsHint
)
403 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_RectangleHint
)
404 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_NoHint
)
405 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_HintFade
)
406 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_AllowFloating
)
407 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_NoVenetianFade
)
408 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_TransparentDrag
)
409 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_AllowActivePane
)
410 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_NoGradient
)
411 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_VerticalGradient
)
412 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_HorizontalGradient
)
415 self
.Bind(wx
.EVT_MENU_RANGE
, self
.OnRestorePerspective
, id=ID_FirstPerspective
,
416 id2
=ID_FirstPerspective
+1000)
419 def OnPaneClose(self
, event
):
421 caption
= event
.GetPane().caption
423 if caption
in ["Tree Pane", "Dock Manager Settings", "Fixed Pane"]:
424 msg
= "Are You Sure You Want To Close This Pane?"
425 dlg
= wx
.MessageDialog(self
, msg
, "AUI Question",
426 wx
.YES_NO | wx
.NO_DEFAULT | wx
.ICON_QUESTION
)
428 if dlg
.ShowModal() in [wx
.ID_NO
, wx
.ID_CANCEL
]:
433 def OnClose(self
, event
):
441 def OnAbout(self
, event
):
443 msg
= "wx.aui Demo\n" + \
444 "An advanced window management library for wxWidgets\n" + \
445 "(c) Copyright 2005-2006, Kirix Corporation"
446 dlg
= wx
.MessageDialog(self
, msg
, "About wx.aui Demo",
447 wx
.OK | wx
.ICON_INFORMATION
)
452 def GetDockArt(self
):
454 return self
._mgr
.GetArtProvider()
462 def OnEraseBackground(self
, event
):
467 def OnSize(self
, event
):
472 def OnSettings(self
, event
):
474 # show the settings pane, and float it
475 floating_pane
= self
._mgr
.GetPane("settings").Float().Show()
477 if floating_pane
.floating_pos
== wx
.DefaultPosition
:
478 floating_pane
.FloatingPosition(self
.GetStartPosition())
483 def OnGradient(self
, event
):
487 if event
.GetId() == ID_NoGradient
:
488 gradient
= wx
.aui
.AUI_GRADIENT_NONE
489 elif event
.GetId() == ID_VerticalGradient
:
490 gradient
= wx
.aui
.AUI_GRADIENT_VERTICAL
491 elif event
.GetId() == ID_HorizontalGradient
:
492 gradient
= wx
.aui
.AUI_GRADIENT_HORIZONTAL
494 self
._mgr
.GetArtProvider().SetMetric(wx
.aui
.AUI_DOCKART_GRADIENT_TYPE
, gradient
)
498 def OnManagerFlag(self
, event
):
503 if eid
in [ ID_TransparentHint
, ID_VenetianBlindsHint
, ID_RectangleHint
, ID_NoHint
]:
504 flags
= self
._mgr
.GetFlags()
505 flags
&= ~wx
.aui
.AUI_MGR_TRANSPARENT_HINT
506 flags
&= ~wx
.aui
.AUI_MGR_VENETIAN_BLINDS_HINT
507 flags
&= ~wx
.aui
.AUI_MGR_RECTANGLE_HINT
508 self
._mgr
.SetFlags(flags
)
510 if eid
== ID_AllowFloating
:
511 flag
= wx
.aui
.AUI_MGR_ALLOW_FLOATING
512 elif eid
== ID_TransparentDrag
:
513 flag
= wx
.aui
.AUI_MGR_TRANSPARENT_DRAG
514 elif eid
== ID_HintFade
:
515 flag
= wx
.aui
.AUI_MGR_HINT_FADE
516 elif eid
== ID_NoVenetianFade
:
517 flag
= wx
.aui
.AUI_MGR_NO_VENETIAN_BLINDS_FADE
518 elif eid
== ID_AllowActivePane
:
519 flag
= wx
.aui
.AUI_MGR_ALLOW_ACTIVE_PANE
520 elif eid
== ID_TransparentHint
:
521 flag
= wx
.aui
.AUI_MGR_TRANSPARENT_HINT
522 elif eid
== ID_VenetianBlindsHint
:
523 flag
= wx
.aui
.AUI_MGR_VENETIAN_BLINDS_HINT
524 elif eid
== ID_RectangleHint
:
525 flag
= wx
.aui
.AUI_MGR_RECTANGLE_HINT
527 self
._mgr
.SetFlags(self
._mgr
.GetFlags() ^ flag
)
530 def OnUpdateUI(self
, event
):
532 flags
= self
._mgr
.GetFlags()
535 if eid
== ID_NoGradient
:
536 event
.Check(self
._mgr
.GetArtProvider().GetMetric(wx
.aui
.AUI_DOCKART_GRADIENT_TYPE
) == wx
.aui
.AUI_GRADIENT_NONE
)
538 elif eid
== ID_VerticalGradient
:
539 event
.Check(self
._mgr
.GetArtProvider().GetMetric(wx
.aui
.AUI_DOCKART_GRADIENT_TYPE
) == wx
.aui
.AUI_GRADIENT_VERTICAL
)
541 elif eid
== ID_HorizontalGradient
:
542 event
.Check(self
._mgr
.GetArtProvider().GetMetric(wx
.aui
.AUI_DOCKART_GRADIENT_TYPE
) == wx
.aui
.AUI_GRADIENT_HORIZONTAL
)
544 elif eid
== ID_AllowFloating
:
545 event
.Check((flags
& wx
.aui
.AUI_MGR_ALLOW_FLOATING
) != 0)
547 elif eid
== ID_TransparentDrag
:
548 event
.Check((flags
& wx
.aui
.AUI_MGR_TRANSPARENT_DRAG
) != 0)
550 elif eid
== ID_TransparentHint
:
551 event
.Check((flags
& wx
.aui
.AUI_MGR_TRANSPARENT_HINT
) != 0)
553 elif eid
== ID_VenetianBlindsHint
:
554 event
.Check((flags
& wx
.aui
.AUI_MGR_VENETIAN_BLINDS_HINT
) != 0)
556 elif eid
== ID_RectangleHint
:
557 event
.Check((flags
& wx
.aui
.AUI_MGR_RECTANGLE_HINT
) != 0)
559 elif eid
== ID_NoHint
:
560 event
.Check(((wx
.aui
.AUI_MGR_TRANSPARENT_HINT |
561 wx
.aui
.AUI_MGR_VENETIAN_BLINDS_HINT |
562 wx
.aui
.AUI_MGR_RECTANGLE_HINT
) & flags
) == 0)
564 elif eid
== ID_HintFade
:
565 event
.Check((flags
& wx
.aui
.AUI_MGR_HINT_FADE
) != 0);
567 elif eid
== ID_NoVenetianFade
:
568 event
.Check((flags
& wx
.aui
.AUI_MGR_NO_VENETIAN_BLINDS_FADE
) != 0);
573 def OnCreatePerspective(self
, event
):
575 dlg
= wx
.TextEntryDialog(self
, "Enter a name for the new perspective:", "AUI Test")
577 dlg
.SetValue(("Perspective %d")%(len(self
._perspectives
)+1))
578 if dlg
.ShowModal() != wx
.ID_OK
:
581 if len(self
._perspectives
) == 0:
582 self
._perspectives
_menu
.AppendSeparator()
584 self
._perspectives
_menu
.Append(ID_FirstPerspective
+ len(self
._perspectives
), dlg
.GetValue())
585 self
._perspectives
.append(self
._mgr
.SavePerspective())
588 def OnCopyPerspective(self
, event
):
590 s
= self
._mgr
.SavePerspective()
592 if wx
.TheClipboard
.Open():
594 wx
.TheClipboard
.SetData(wx
.TextDataObject(s
))
595 wx
.TheClipboard
.Close()
597 def OnRestorePerspective(self
, event
):
599 self
._mgr
.LoadPerspective(self
._perspectives
[event
.GetId() - ID_FirstPerspective
])
602 def GetStartPosition(self
):
606 pt
= self
.ClientToScreen(wx
.Point(0, 0))
608 return wx
.Point(pt
.x
+ x
, pt
.y
+ x
)
611 def OnCreateTree(self
, event
):
612 self
._mgr
.AddPane(self
.CreateTreeCtrl(), wx
.aui
.AuiPaneInfo().
613 Caption("Tree Control").
614 Float().FloatingPosition(self
.GetStartPosition()).
615 FloatingSize(wx
.Size(150, 300)).CloseButton(True).MaximizeButton(True))
619 def OnCreateGrid(self
, event
):
620 self
._mgr
.AddPane(self
.CreateGrid(), wx
.aui
.AuiPaneInfo().
622 Float().FloatingPosition(self
.GetStartPosition()).
623 FloatingSize(wx
.Size(300, 200)).CloseButton(True).MaximizeButton(True))
627 def OnCreateHTML(self
, event
):
628 self
._mgr
.AddPane(self
.CreateHTMLCtrl(), wx
.aui
.AuiPaneInfo().
629 Caption("HTML Content").
630 Float().FloatingPosition(self
.GetStartPosition()).
631 FloatingSize(wx
.Size(300, 200)).CloseButton(True).MaximizeButton(True))
635 def OnCreateText(self
, event
):
636 self
._mgr
.AddPane(self
.CreateTextCtrl(), wx
.aui
.AuiPaneInfo().
637 Caption("Text Control").
638 Float().FloatingPosition(self
.GetStartPosition()).
639 CloseButton(True).MaximizeButton(True))
643 def OnCreateSizeReport(self
, event
):
644 self
._mgr
.AddPane(self
.CreateSizeReportCtrl(), wx
.aui
.AuiPaneInfo().
645 Caption("Client Size Reporter").
646 Float().FloatingPosition(self
.GetStartPosition()).
647 CloseButton(True).MaximizeButton(True))
651 def OnChangeContentPane(self
, event
):
653 self
._mgr
.GetPane("grid_content").Show(event
.GetId() == ID_GridContent
)
654 self
._mgr
.GetPane("text_content").Show(event
.GetId() == ID_TextContent
)
655 self
._mgr
.GetPane("tree_content").Show(event
.GetId() == ID_TreeContent
)
656 self
._mgr
.GetPane("sizereport_content").Show(event
.GetId() == ID_SizeReportContent
)
657 self
._mgr
.GetPane("html_content").Show(event
.GetId() == ID_HTMLContent
)
661 def CreateTextCtrl(self
):
663 text
= ("This is text box %d")%(self
.n
+ 1)
665 return wx
.TextCtrl(self
,-1, text
, wx
.Point(0, 0), wx
.Size(150, 90),
666 wx
.NO_BORDER | wx
.TE_MULTILINE
)
670 def CreateGrid(self
):
672 grid
= wx
.grid
.Grid(self
, -1, wx
.Point(0, 0), wx
.Size(150, 250),
673 wx
.NO_BORDER | wx
.WANTS_CHARS
)
675 grid
.CreateGrid(50, 20)
680 def CreateTreeCtrl(self
):
682 tree
= wx
.TreeCtrl(self
, -1, wx
.Point(0, 0), wx
.Size(160, 250),
683 wx
.TR_DEFAULT_STYLE | wx
.NO_BORDER
)
685 root
= tree
.AddRoot("AUI Project")
688 imglist
= wx
.ImageList(16, 16, True, 2)
689 imglist
.Add(wx
.ArtProvider_GetBitmap(wx
.ART_FOLDER
, wx
.ART_OTHER
, wx
.Size(16,16)))
690 imglist
.Add(wx
.ArtProvider_GetBitmap(wx
.ART_NORMAL_FILE
, wx
.ART_OTHER
, wx
.Size(16,16)))
691 tree
.AssignImageList(imglist
)
693 items
.append(tree
.AppendItem(root
, "Item 1", 0))
694 items
.append(tree
.AppendItem(root
, "Item 2", 0))
695 items
.append(tree
.AppendItem(root
, "Item 3", 0))
696 items
.append(tree
.AppendItem(root
, "Item 4", 0))
697 items
.append(tree
.AppendItem(root
, "Item 5", 0))
699 for ii
in xrange(len(items
)):
702 tree
.AppendItem(id, "Subitem 1", 1)
703 tree
.AppendItem(id, "Subitem 2", 1)
704 tree
.AppendItem(id, "Subitem 3", 1)
705 tree
.AppendItem(id, "Subitem 4", 1)
706 tree
.AppendItem(id, "Subitem 5", 1)
713 def CreateSizeReportCtrl(self
, width
=80, height
=80):
715 ctrl
= SizeReportCtrl(self
, -1, wx
.DefaultPosition
,
716 wx
.Size(width
, height
), self
._mgr
)
720 def CreateHTMLCtrl(self
):
721 ctrl
= wx
.html
.HtmlWindow(self
, -1, wx
.DefaultPosition
, wx
.Size(400, 300))
722 if "gtk2" in wx
.PlatformInfo
:
723 ctrl
.SetStandardFonts()
724 ctrl
.SetPage(self
.GetIntroText())
728 def GetIntroText(self
):
732 # -- wx.SizeReportCtrl --
733 # (a utility control that always reports it's client size)
735 class SizeReportCtrl(wx
.PyControl
):
737 def __init__(self
, parent
, id=wx
.ID_ANY
, pos
=wx
.DefaultPosition
,
738 size
=wx
.DefaultSize
, mgr
=None):
740 wx
.PyControl
.__init
__(self
, parent
, id, pos
, size
, wx
.NO_BORDER
)
744 self
.Bind(wx
.EVT_PAINT
, self
.OnPaint
)
745 self
.Bind(wx
.EVT_SIZE
, self
.OnSize
)
746 self
.Bind(wx
.EVT_ERASE_BACKGROUND
, self
.OnEraseBackground
)
749 def OnPaint(self
, event
):
751 dc
= wx
.PaintDC(self
)
753 size
= self
.GetClientSize()
754 s
= ("Size: %d x %d")%(size
.x
, size
.y
)
756 dc
.SetFont(wx
.NORMAL_FONT
)
757 w
, height
= dc
.GetTextExtent(s
)
759 dc
.SetBrush(wx
.WHITE_BRUSH
)
760 dc
.SetPen(wx
.WHITE_PEN
)
761 dc
.DrawRectangle(0, 0, size
.x
, size
.y
)
762 dc
.SetPen(wx
.LIGHT_GREY_PEN
)
763 dc
.DrawLine(0, 0, size
.x
, size
.y
)
764 dc
.DrawLine(0, size
.y
, size
.x
, 0)
765 dc
.DrawText(s
, (size
.x
-w
)/2, ((size
.y
-(height
*5))/2))
769 pi
= self
._mgr
.GetPane(self
)
771 s
= ("Layer: %d")%pi
.dock_layer
772 w
, h
= dc
.GetTextExtent(s
)
773 dc
.DrawText(s
, (size
.x
-w
)/2, ((size
.y
-(height
*5))/2)+(height
*1))
775 s
= ("Dock: %d Row: %d")%(pi
.dock_direction
, pi
.dock_row
)
776 w
, h
= dc
.GetTextExtent(s
)
777 dc
.DrawText(s
, (size
.x
-w
)/2, ((size
.y
-(height
*5))/2)+(height
*2))
779 s
= ("Position: %d")%pi
.dock_pos
780 w
, h
= dc
.GetTextExtent(s
)
781 dc
.DrawText(s
, (size
.x
-w
)/2, ((size
.y
-(height
*5))/2)+(height
*3))
783 s
= ("Proportion: %d")%pi
.dock_proportion
784 w
, h
= dc
.GetTextExtent(s
)
785 dc
.DrawText(s
, (size
.x
-w
)/2, ((size
.y
-(height
*5))/2)+(height
*4))
788 def OnEraseBackground(self
, event
):
789 # intentionally empty
793 def OnSize(self
, event
):
799 ID_PaneBorderSize
= wx
.ID_HIGHEST
+ 1
800 ID_SashSize
= ID_PaneBorderSize
+ 1
801 ID_CaptionSize
= ID_PaneBorderSize
+ 2
802 ID_BackgroundColor
= ID_PaneBorderSize
+ 3
803 ID_SashColor
= ID_PaneBorderSize
+ 4
804 ID_InactiveCaptionColor
= ID_PaneBorderSize
+ 5
805 ID_InactiveCaptionGradientColor
= ID_PaneBorderSize
+ 6
806 ID_InactiveCaptionTextColor
= ID_PaneBorderSize
+ 7
807 ID_ActiveCaptionColor
= ID_PaneBorderSize
+ 8
808 ID_ActiveCaptionGradientColor
= ID_PaneBorderSize
+ 9
809 ID_ActiveCaptionTextColor
= ID_PaneBorderSize
+ 10
810 ID_BorderColor
= ID_PaneBorderSize
+ 11
811 ID_GripperColor
= ID_PaneBorderSize
+ 12
813 class SettingsPanel(wx
.Panel
):
815 def __init__(self
, parent
, frame
):
817 wx
.Panel
.__init
__(self
, parent
, wx
.ID_ANY
, wx
.DefaultPosition
,
822 vert
= wx
.BoxSizer(wx
.VERTICAL
)
824 s1
= wx
.BoxSizer(wx
.HORIZONTAL
)
825 self
._border
_size
= wx
.SpinCtrl(self
, ID_PaneBorderSize
, "", wx
.DefaultPosition
, wx
.Size(50,20))
826 s1
.Add((1, 1), 1, wx
.EXPAND
)
827 s1
.Add(wx
.StaticText(self
, -1, "Pane Border Size:"))
828 s1
.Add(self
._border
_size
)
829 s1
.Add((1, 1), 1, wx
.EXPAND
)
830 s1
.SetItemMinSize(1, (180, 20))
831 #vert.Add(s1, 0, wx.EXPAND | wxLEFT | wxBOTTOM, 5)
833 s2
= wx
.BoxSizer(wx
.HORIZONTAL
)
834 self
._sash
_size
= wx
.SpinCtrl(self
, ID_SashSize
, "", wx
.DefaultPosition
, wx
.Size(50,20))
835 s2
.Add((1, 1), 1, wx
.EXPAND
)
836 s2
.Add(wx
.StaticText(self
, -1, "Sash Size:"))
837 s2
.Add(self
._sash
_size
)
838 s2
.Add((1, 1), 1, wx
.EXPAND
)
839 s2
.SetItemMinSize(1, (180, 20))
840 #vert.Add(s2, 0, wx.EXPAND | wxLEFT | wxBOTTOM, 5)
842 s3
= wx
.BoxSizer(wx
.HORIZONTAL
)
843 self
._caption
_size
= wx
.SpinCtrl(self
, ID_CaptionSize
, "", wx
.DefaultPosition
, wx
.Size(50,20))
844 s3
.Add((1, 1), 1, wx
.EXPAND
)
845 s3
.Add(wx
.StaticText(self
, -1, "Caption Size:"))
846 s3
.Add(self
._caption
_size
)
847 s3
.Add((1, 1), 1, wx
.EXPAND
)
848 s3
.SetItemMinSize(1, (180, 20))
849 #vert.Add(s3, 0, wx.EXPAND | wxLEFT | wxBOTTOM, 5)
851 #vert.Add(1, 1, 1, wx.EXPAND)
853 b
= self
.CreateColorBitmap(wx
.BLACK
)
855 s4
= wx
.BoxSizer(wx
.HORIZONTAL
)
856 self
._background
_color
= wx
.BitmapButton(self
, ID_BackgroundColor
, b
, wx
.DefaultPosition
, wx
.Size(50,25))
857 s4
.Add((1, 1), 1, wx
.EXPAND
)
858 s4
.Add(wx
.StaticText(self
, -1, "Background Color:"))
859 s4
.Add(self
._background
_color
)
860 s4
.Add((1, 1), 1, wx
.EXPAND
)
861 s4
.SetItemMinSize(1, (180, 20))
863 s5
= wx
.BoxSizer(wx
.HORIZONTAL
)
864 self
._sash
_color
= wx
.BitmapButton(self
, ID_SashColor
, b
, wx
.DefaultPosition
, wx
.Size(50,25))
865 s5
.Add((1, 1), 1, wx
.EXPAND
)
866 s5
.Add(wx
.StaticText(self
, -1, "Sash Color:"))
867 s5
.Add(self
._sash
_color
)
868 s5
.Add((1, 1), 1, wx
.EXPAND
)
869 s5
.SetItemMinSize(1, (180, 20))
871 s6
= wx
.BoxSizer(wx
.HORIZONTAL
)
872 self
._inactive
_caption
_color
= wx
.BitmapButton(self
, ID_InactiveCaptionColor
, b
,
873 wx
.DefaultPosition
, wx
.Size(50,25))
874 s6
.Add((1, 1), 1, wx
.EXPAND
)
875 s6
.Add(wx
.StaticText(self
, -1, "Normal Caption:"))
876 s6
.Add(self
._inactive
_caption
_color
)
877 s6
.Add((1, 1), 1, wx
.EXPAND
)
878 s6
.SetItemMinSize(1, (180, 20))
880 s7
= wx
.BoxSizer(wx
.HORIZONTAL
)
881 self
._inactive
_caption
_gradient
_color
= wx
.BitmapButton(self
, ID_InactiveCaptionGradientColor
,
882 b
, wx
.DefaultPosition
, wx
.Size(50,25))
883 s7
.Add((1, 1), 1, wx
.EXPAND
)
884 s7
.Add(wx
.StaticText(self
, -1, "Normal Caption Gradient:"))
885 s7
.Add(self
._inactive
_caption
_gradient
_color
)
886 s7
.Add((1, 1), 1, wx
.EXPAND
)
887 s7
.SetItemMinSize(1, (180, 20))
889 s8
= wx
.BoxSizer(wx
.HORIZONTAL
)
890 self
._inactive
_caption
_text
_color
= wx
.BitmapButton(self
, ID_InactiveCaptionTextColor
, b
,
891 wx
.DefaultPosition
, wx
.Size(50,25))
892 s8
.Add((1, 1), 1, wx
.EXPAND
)
893 s8
.Add(wx
.StaticText(self
, -1, "Normal Caption Text:"))
894 s8
.Add(self
._inactive
_caption
_text
_color
)
895 s8
.Add((1, 1), 1, wx
.EXPAND
)
896 s8
.SetItemMinSize(1, (180, 20))
898 s9
= wx
.BoxSizer(wx
.HORIZONTAL
)
899 self
._active
_caption
_color
= wx
.BitmapButton(self
, ID_ActiveCaptionColor
, b
,
900 wx
.DefaultPosition
, wx
.Size(50,25))
901 s9
.Add((1, 1), 1, wx
.EXPAND
)
902 s9
.Add(wx
.StaticText(self
, -1, "Active Caption:"))
903 s9
.Add(self
._active
_caption
_color
)
904 s9
.Add((1, 1), 1, wx
.EXPAND
)
905 s9
.SetItemMinSize(1, (180, 20))
907 s10
= wx
.BoxSizer(wx
.HORIZONTAL
)
908 self
._active
_caption
_gradient
_color
= wx
.BitmapButton(self
, ID_ActiveCaptionGradientColor
,
909 b
, wx
.DefaultPosition
, wx
.Size(50,25))
910 s10
.Add((1, 1), 1, wx
.EXPAND
)
911 s10
.Add(wx
.StaticText(self
, -1, "Active Caption Gradient:"))
912 s10
.Add(self
._active
_caption
_gradient
_color
)
913 s10
.Add((1, 1), 1, wx
.EXPAND
)
914 s10
.SetItemMinSize(1, (180, 20))
916 s11
= wx
.BoxSizer(wx
.HORIZONTAL
)
917 self
._active
_caption
_text
_color
= wx
.BitmapButton(self
, ID_ActiveCaptionTextColor
,
918 b
, wx
.DefaultPosition
, wx
.Size(50,25))
919 s11
.Add((1, 1), 1, wx
.EXPAND
)
920 s11
.Add(wx
.StaticText(self
, -1, "Active Caption Text:"))
921 s11
.Add(self
._active
_caption
_text
_color
)
922 s11
.Add((1, 1), 1, wx
.EXPAND
)
923 s11
.SetItemMinSize(1, (180, 20))
925 s12
= wx
.BoxSizer(wx
.HORIZONTAL
)
926 self
._border
_color
= wx
.BitmapButton(self
, ID_BorderColor
, b
, wx
.DefaultPosition
,
928 s12
.Add((1, 1), 1, wx
.EXPAND
)
929 s12
.Add(wx
.StaticText(self
, -1, "Border Color:"))
930 s12
.Add(self
._border
_color
)
931 s12
.Add((1, 1), 1, wx
.EXPAND
)
932 s12
.SetItemMinSize(1, (180, 20))
934 s13
= wx
.BoxSizer(wx
.HORIZONTAL
)
935 self
._gripper
_color
= wx
.BitmapButton(self
, ID_GripperColor
, b
, wx
.DefaultPosition
,
937 s13
.Add((1, 1), 1, wx
.EXPAND
)
938 s13
.Add(wx
.StaticText(self
, -1, "Gripper Color:"))
939 s13
.Add(self
._gripper
_color
)
940 s13
.Add((1, 1), 1, wx
.EXPAND
)
941 s13
.SetItemMinSize(1, (180, 20))
943 grid_sizer
= wx
.GridSizer(0, 2)
944 grid_sizer
.SetHGap(5)
951 grid_sizer
.Add((1, 1))
960 cont_sizer
= wx
.BoxSizer(wx
.VERTICAL
)
961 cont_sizer
.Add(grid_sizer
, 1, wx
.EXPAND | wx
.ALL
, 5)
962 self
.SetSizer(cont_sizer
)
963 self
.GetSizer().SetSizeHints(self
)
965 self
._border
_size
.SetValue(frame
.GetDockArt().GetMetric(wx
.aui
.AUI_DOCKART_PANE_BORDER_SIZE
))
966 self
._sash
_size
.SetValue(frame
.GetDockArt().GetMetric(wx
.aui
.AUI_DOCKART_SASH_SIZE
))
967 self
._caption
_size
.SetValue(frame
.GetDockArt().GetMetric(wx
.aui
.AUI_DOCKART_CAPTION_SIZE
))
971 self
.Bind(wx
.EVT_SPINCTRL
, self
.OnPaneBorderSize
, id=ID_PaneBorderSize
)
972 self
.Bind(wx
.EVT_SPINCTRL
, self
.OnSashSize
, id=ID_SashSize
)
973 self
.Bind(wx
.EVT_SPINCTRL
, self
.OnCaptionSize
, id=ID_CaptionSize
)
974 self
.Bind(wx
.EVT_BUTTON
, self
.OnSetColor
, id=ID_BackgroundColor
)
975 self
.Bind(wx
.EVT_BUTTON
, self
.OnSetColor
, id=ID_SashColor
)
976 self
.Bind(wx
.EVT_BUTTON
, self
.OnSetColor
, id=ID_InactiveCaptionColor
)
977 self
.Bind(wx
.EVT_BUTTON
, self
.OnSetColor
, id=ID_InactiveCaptionGradientColor
)
978 self
.Bind(wx
.EVT_BUTTON
, self
.OnSetColor
, id=ID_InactiveCaptionTextColor
)
979 self
.Bind(wx
.EVT_BUTTON
, self
.OnSetColor
, id=ID_ActiveCaptionColor
)
980 self
.Bind(wx
.EVT_BUTTON
, self
.OnSetColor
, id=ID_ActiveCaptionGradientColor
)
981 self
.Bind(wx
.EVT_BUTTON
, self
.OnSetColor
, id=ID_ActiveCaptionTextColor
)
982 self
.Bind(wx
.EVT_BUTTON
, self
.OnSetColor
, id=ID_BorderColor
)
983 self
.Bind(wx
.EVT_BUTTON
, self
.OnSetColor
, id=ID_GripperColor
)
986 def CreateColorBitmap(self
, c
):
987 image
= wx
.EmptyImage(25, 14)
992 if x
== 0 or x
== 24 or y
== 0 or y
== 13:
995 image
.SetRGB(x
, y
, pixcol
.Red(), pixcol
.Green(), pixcol
.Blue())
997 return image
.ConvertToBitmap()
1000 def UpdateColors(self
):
1002 bk
= self
._frame
.GetDockArt().GetColour(wx
.aui
.AUI_DOCKART_BACKGROUND_COLOUR
)
1003 self
._background
_color
.SetBitmapLabel(self
.CreateColorBitmap(bk
))
1005 cap
= self
._frame
.GetDockArt().GetColour(wx
.aui
.AUI_DOCKART_INACTIVE_CAPTION_COLOUR
)
1006 self
._inactive
_caption
_color
.SetBitmapLabel(self
.CreateColorBitmap(cap
))
1008 capgrad
= self
._frame
.GetDockArt().GetColour(wx
.aui
.AUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR
)
1009 self
._inactive
_caption
_gradient
_color
.SetBitmapLabel(self
.CreateColorBitmap(capgrad
))
1011 captxt
= self
._frame
.GetDockArt().GetColour(wx
.aui
.AUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR
)
1012 self
._inactive
_caption
_text
_color
.SetBitmapLabel(self
.CreateColorBitmap(captxt
))
1014 acap
= self
._frame
.GetDockArt().GetColour(wx
.aui
.AUI_DOCKART_ACTIVE_CAPTION_COLOUR
)
1015 self
._active
_caption
_color
.SetBitmapLabel(self
.CreateColorBitmap(acap
))
1017 acapgrad
= self
._frame
.GetDockArt().GetColour(wx
.aui
.AUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR
)
1018 self
._active
_caption
_gradient
_color
.SetBitmapLabel(self
.CreateColorBitmap(acapgrad
))
1020 acaptxt
= self
._frame
.GetDockArt().GetColour(wx
.aui
.AUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR
)
1021 self
._active
_caption
_text
_color
.SetBitmapLabel(self
.CreateColorBitmap(acaptxt
))
1023 sash
= self
._frame
.GetDockArt().GetColour(wx
.aui
.AUI_DOCKART_SASH_COLOUR
)
1024 self
._sash
_color
.SetBitmapLabel(self
.CreateColorBitmap(sash
))
1026 border
= self
._frame
.GetDockArt().GetColour(wx
.aui
.AUI_DOCKART_BORDER_COLOUR
)
1027 self
._border
_color
.SetBitmapLabel(self
.CreateColorBitmap(border
))
1029 gripper
= self
._frame
.GetDockArt().GetColour(wx
.aui
.AUI_DOCKART_GRIPPER_COLOUR
)
1030 self
._gripper
_color
.SetBitmapLabel(self
.CreateColorBitmap(gripper
))
1033 def OnPaneBorderSize(self
, event
):
1035 self
._frame
.GetDockArt().SetMetric(wx
.aui
.AUI_DOCKART_PANE_BORDER_SIZE
,
1037 self
._frame
.DoUpdate()
1040 def OnSashSize(self
, event
):
1042 self
._frame
.GetDockArt().SetMetric(wx
.aui
.AUI_DOCKART_SASH_SIZE
,
1044 self
._frame
.DoUpdate()
1047 def OnCaptionSize(self
, event
):
1049 self
._frame
.GetDockArt().SetMetric(wx
.aui
.AUI_DOCKART_CAPTION_SIZE
,
1051 self
._frame
.DoUpdate()
1054 def OnSetColor(self
, event
):
1056 dlg
= wx
.ColourDialog(self
._frame
)
1058 dlg
.SetTitle("Color Picker")
1060 if dlg
.ShowModal() != wx
.ID_OK
:
1064 if event
.GetId() == ID_BackgroundColor
:
1065 var
= wx
.aui
.AUI_DOCKART_BACKGROUND_COLOUR
1066 elif event
.GetId() == ID_SashColor
:
1067 var
= wx
.aui
.AUI_DOCKART_SASH_COLOUR
1068 elif event
.GetId() == ID_InactiveCaptionColor
:
1069 var
= wx
.aui
.AUI_DOCKART_INACTIVE_CAPTION_COLOUR
1070 elif event
.GetId() == ID_InactiveCaptionGradientColor
:
1071 var
= wx
.aui
.AUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR
1072 elif event
.GetId() == ID_InactiveCaptionTextColor
:
1073 var
= wx
.aui
.AUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR
1074 elif event
.GetId() == ID_ActiveCaptionColor
:
1075 var
= wx
.aui
.AUI_DOCKART_ACTIVE_CAPTION_COLOUR
1076 elif event
.GetId() == ID_ActiveCaptionGradientColor
:
1077 var
= wx
.aui
.AUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR
1078 elif event
.GetId() == ID_ActiveCaptionTextColor
:
1079 var
= wx
.aui
.AUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR
1080 elif event
.GetId() == ID_BorderColor
:
1081 var
= wx
.aui
.AUI_DOCKART_BORDER_COLOUR
1082 elif event
.GetId() == ID_GripperColor
:
1083 var
= wx
.aui
.AUI_DOCKART_GRIPPER_COLOUR
1087 self
._frame
.GetDockArt().SetColor(var
, dlg
.GetColourData().GetColour())
1088 self
._frame
.DoUpdate()
1093 #----------------------------------------------------------------------
1095 class TestPanel(wx
.Panel
):
1096 def __init__(self
, parent
, log
):
1098 wx
.Panel
.__init
__(self
, parent
, -1)
1099 b
= wx
.Button(self
, -1, "Show the wx.aui Demo Frame", (50,50))
1100 self
.Bind(wx
.EVT_BUTTON
, self
.OnButton
, b
)
1102 def OnButton(self
, evt
):
1103 frame
= PyAUIFrame(self
, wx
.ID_ANY
, "wx.aui wxPython Demo", size
=(750, 590))
1106 #----------------------------------------------------------------------
1108 def runTest(frame
, nb
, log
):
1109 win
= TestPanel(nb
, log
)
1112 #----------------------------------------------------------------------
1118 <h3>wx.aui, the Advanced User Interface module</h3>
1120 <br/><b>Overview</b><br/>
1122 <p>wx.aui is an Advanced User Interface library for the wxWidgets toolkit
1123 that allows developers to create high-quality, cross-platform user
1124 interfaces quickly and easily.</p>
1126 <p><b>Features</b></p>
1128 <p>With wx.aui developers can create application frameworks with:</p>
1131 <li>Native, dockable floating frames</li>
1132 <li>Perspective saving and loading</li>
1133 <li>Native toolbars incorporating real-time, "spring-loaded" dragging</li>
1134 <li>Customizable floating/docking behavior</li>
1135 <li>Completely customizable look-and-feel</li>
1136 <li>Optional transparent window effects (while dragging or docking)</li>
1145 if __name__
== '__main__':
1148 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])