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())
225 self
._mgr
.AddPane(self
.CreateSizeReportCtrl(), wx
.aui
.AuiPaneInfo().
226 Name("test2").Caption("Client Size Reporter").
227 Bottom().Position(1))
229 self
._mgr
.AddPane(self
.CreateSizeReportCtrl(), wx
.aui
.AuiPaneInfo().
230 Name("test3").Caption("Client Size Reporter").
233 self
._mgr
.AddPane(self
.CreateSizeReportCtrl(), wx
.aui
.AuiPaneInfo().
234 Name("test4").Caption("Pane Caption").
237 self
._mgr
.AddPane(self
.CreateSizeReportCtrl(), wx
.aui
.AuiPaneInfo().
238 Name("test5").Caption("Pane Caption").
241 self
._mgr
.AddPane(self
.CreateSizeReportCtrl(), wx
.aui
.AuiPaneInfo().
242 Name("test6").Caption("Client Size Reporter").
245 self
._mgr
.AddPane(self
.CreateSizeReportCtrl(), wx
.aui
.AuiPaneInfo().
246 Name("test7").Caption("Client Size Reporter").
249 self
._mgr
.AddPane(self
.CreateTreeCtrl(), wx
.aui
.AuiPaneInfo().
250 Name("test8").Caption("Tree Pane").
251 Left().Layer(1).Position(1))
253 self
._mgr
.AddPane(self
.CreateSizeReportCtrl(), wx
.aui
.AuiPaneInfo().
254 Name("test9").Caption("Min Size 200x100").
255 BestSize(wx
.Size(200,100)).MinSize(wx
.Size(200,100)).
258 self
._mgr
.AddPane(self
.CreateTextCtrl(), wx
.aui
.AuiPaneInfo().
259 Name("test10").Caption("Text Pane").
260 Bottom().Layer(1).Position(1))
262 self
._mgr
.AddPane(self
.CreateSizeReportCtrl(), wx
.aui
.AuiPaneInfo().
263 Name("test11").Caption("Fixed Pane").
264 Bottom().Layer(1).Position(2).Fixed())
266 self
._mgr
.AddPane(SettingsPanel(self
, self
), wx
.aui
.AuiPaneInfo().
267 Name("settings").Caption("Dock Manager Settings").
268 Dockable(False).Float().Hide())
270 # create some center panes
272 self
._mgr
.AddPane(self
.CreateGrid(), wx
.aui
.AuiPaneInfo().Name("grid_content").
275 self
._mgr
.AddPane(self
.CreateTreeCtrl(), wx
.aui
.AuiPaneInfo().Name("tree_content").
278 self
._mgr
.AddPane(self
.CreateSizeReportCtrl(), wx
.aui
.AuiPaneInfo().Name("sizereport_content").
281 self
._mgr
.AddPane(self
.CreateTextCtrl(), wx
.aui
.AuiPaneInfo().Name("text_content").
284 self
._mgr
.AddPane(self
.CreateHTMLCtrl(), wx
.aui
.AuiPaneInfo().Name("html_content").
287 # add the toolbars to the manager
289 self
._mgr
.AddPane(tb1
, wx
.aui
.AuiPaneInfo().
290 Name("tb1").Caption("Big Toolbar").
292 LeftDockable(False).RightDockable(False))
294 self
._mgr
.AddPane(tb2
, wx
.aui
.AuiPaneInfo().
295 Name("tb2").Caption("Toolbar 2").
296 ToolbarPane().Top().Row(1).
297 LeftDockable(False).RightDockable(False))
299 self
._mgr
.AddPane(tb3
, wx
.aui
.AuiPaneInfo().
300 Name("tb3").Caption("Toolbar 3").
301 ToolbarPane().Top().Row(1).Position(1).
302 LeftDockable(False).RightDockable(False))
304 self
._mgr
.AddPane(tb4
, wx
.aui
.AuiPaneInfo().
305 Name("tb4").Caption("Sample Bookmark Toolbar").
306 ToolbarPane().Top().Row(2).
307 LeftDockable(False).RightDockable(False))
309 self
._mgr
.AddPane(tb5
, wx
.aui
.AuiPaneInfo().
310 Name("tbvert").Caption("Sample Vertical Toolbar").
311 ToolbarPane().Left().GripperTop().
312 TopDockable(False).BottomDockable(False))
314 self
._mgr
.AddPane(wx
.Button(self
, -1, "Test Button"),
315 wx
.aui
.AuiPaneInfo().Name("tb5").
316 ToolbarPane().Top().Row(2).Position(1).
317 LeftDockable(False).RightDockable(False))
319 # make some default perspectives
321 self
._mgr
.GetPane("tbvert").Hide()
323 perspective_all
= self
._mgr
.SavePerspective()
325 all_panes
= self
._mgr
.GetAllPanes()
327 for ii
in xrange(len(all_panes
)):
328 if not all_panes
[ii
].IsToolbar():
331 self
._mgr
.GetPane("tb1").Hide()
332 self
._mgr
.GetPane("tb5").Hide()
333 self
._mgr
.GetPane("test8").Show().Left().Layer(0).Row(0).Position(0)
334 self
._mgr
.GetPane("test10").Show().Bottom().Layer(0).Row(0).Position(0)
335 self
._mgr
.GetPane("html_content").Show()
337 perspective_default
= self
._mgr
.SavePerspective()
339 for ii
in xrange(len(all_panes
)):
340 if not all_panes
[ii
].IsToolbar():
343 self
._mgr
.GetPane("tb1").Hide()
344 self
._mgr
.GetPane("tb5").Hide()
345 self
._mgr
.GetPane("tbvert").Show()
346 self
._mgr
.GetPane("grid_content").Show()
347 self
._mgr
.GetPane("test8").Show().Left().Layer(0).Row(0).Position(0)
348 self
._mgr
.GetPane("test10").Show().Bottom().Layer(0).Row(0).Position(0)
349 self
._mgr
.GetPane("html_content").Show()
351 perspective_vert
= self
._mgr
.SavePerspective()
353 self
._perspectives
.append(perspective_default
)
354 self
._perspectives
.append(perspective_all
)
355 self
._perspectives
.append(perspective_vert
)
357 self
._mgr
.GetPane("tbvert").Hide()
358 self
._mgr
.GetPane("grid_content").Hide()
360 # "commit" all changes made to FrameManager
363 self
.Bind(wx
.EVT_ERASE_BACKGROUND
, self
.OnEraseBackground
)
364 self
.Bind(wx
.EVT_SIZE
, self
.OnSize
)
365 self
.Bind(wx
.EVT_CLOSE
, self
.OnClose
)
367 # Show How To Use The Closing Panes Event
368 self
.Bind(wx
.aui
.EVT_AUI_PANEBUTTON
, self
.OnPaneButton
)
370 self
.Bind(wx
.EVT_MENU
, self
.OnCreateTree
, id=ID_CreateTree
)
371 self
.Bind(wx
.EVT_MENU
, self
.OnCreateGrid
, id=ID_CreateGrid
)
372 self
.Bind(wx
.EVT_MENU
, self
.OnCreateText
, id=ID_CreateText
)
373 self
.Bind(wx
.EVT_MENU
, self
.OnCreateHTML
, id=ID_CreateHTML
)
374 self
.Bind(wx
.EVT_MENU
, self
.OnCreateSizeReport
, id=ID_CreateSizeReport
)
375 self
.Bind(wx
.EVT_MENU
, self
.OnCreatePerspective
, id=ID_CreatePerspective
)
376 self
.Bind(wx
.EVT_MENU
, self
.OnCopyPerspective
, id=ID_CopyPerspective
)
378 self
.Bind(wx
.EVT_MENU
, self
.OnManagerFlag
, id=ID_AllowFloating
)
379 self
.Bind(wx
.EVT_MENU
, self
.OnManagerFlag
, id=ID_TransparentHint
)
380 self
.Bind(wx
.EVT_MENU
, self
.OnManagerFlag
, id=ID_VenetianBlindsHint
)
381 self
.Bind(wx
.EVT_MENU
, self
.OnManagerFlag
, id=ID_RectangleHint
)
382 self
.Bind(wx
.EVT_MENU
, self
.OnManagerFlag
, id=ID_NoHint
)
383 self
.Bind(wx
.EVT_MENU
, self
.OnManagerFlag
, id=ID_HintFade
)
384 self
.Bind(wx
.EVT_MENU
, self
.OnManagerFlag
, id=ID_NoVenetianFade
)
385 self
.Bind(wx
.EVT_MENU
, self
.OnManagerFlag
, id=ID_TransparentDrag
)
386 self
.Bind(wx
.EVT_MENU
, self
.OnManagerFlag
, id=ID_AllowActivePane
)
388 self
.Bind(wx
.EVT_MENU
, self
.OnGradient
, id=ID_NoGradient
)
389 self
.Bind(wx
.EVT_MENU
, self
.OnGradient
, id=ID_VerticalGradient
)
390 self
.Bind(wx
.EVT_MENU
, self
.OnGradient
, id=ID_HorizontalGradient
)
391 self
.Bind(wx
.EVT_MENU
, self
.OnSettings
, id=ID_Settings
)
392 self
.Bind(wx
.EVT_MENU
, self
.OnChangeContentPane
, id=ID_GridContent
)
393 self
.Bind(wx
.EVT_MENU
, self
.OnChangeContentPane
, id=ID_TreeContent
)
394 self
.Bind(wx
.EVT_MENU
, self
.OnChangeContentPane
, id=ID_TextContent
)
395 self
.Bind(wx
.EVT_MENU
, self
.OnChangeContentPane
, id=ID_SizeReportContent
)
396 self
.Bind(wx
.EVT_MENU
, self
.OnChangeContentPane
, id=ID_HTMLContent
)
397 self
.Bind(wx
.EVT_MENU
, self
.OnClose
, id=wx
.ID_EXIT
)
398 self
.Bind(wx
.EVT_MENU
, self
.OnAbout
, id=ID_About
)
400 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_TransparentHint
)
401 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_VenetianBlindsHint
)
402 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_RectangleHint
)
403 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_NoHint
)
404 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_HintFade
)
405 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_AllowFloating
)
406 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_NoVenetianFade
)
407 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_TransparentDrag
)
408 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_AllowActivePane
)
409 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_NoGradient
)
410 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_VerticalGradient
)
411 self
.Bind(wx
.EVT_UPDATE_UI
, self
.OnUpdateUI
, id=ID_HorizontalGradient
)
414 self
.Bind(wx
.EVT_MENU_RANGE
, self
.OnRestorePerspective
, id=ID_FirstPerspective
,
415 id2
=ID_FirstPerspective
+1000)
418 def OnPaneButton(self
, event
):
420 caption
= event
.GetPane().caption
422 if caption
in ["Tree Pane", "Dock Manager Settings", "Fixed Pane"]:
423 msg
= "Are You Sure You Want To Close This Pane?"
424 dlg
= wx
.MessageDialog(self
, msg
, "AUI Question",
425 wx
.YES_NO | wx
.NO_DEFAULT | wx
.CANCEL | wx
.ICON_QUESTION
)
427 if dlg
.ShowModal() in [wx
.ID_NO
, wx
.ID_CANCEL
]:
436 def OnClose(self
, event
):
444 def OnAbout(self
, event
):
446 msg
= "wx.aui Demo\n" + \
447 "An advanced window management library for wxWidgets\n" + \
448 "(c) Copyright 2005-2006, Kirix Corporation"
449 dlg
= wx
.MessageDialog(self
, msg
, "About wx.aui Demo",
450 wx
.OK | wx
.ICON_INFORMATION
)
455 def GetDockArt(self
):
457 return self
._mgr
.GetArtProvider()
465 def OnEraseBackground(self
, event
):
470 def OnSize(self
, event
):
475 def OnSettings(self
, event
):
477 # show the settings pane, and float it
478 floating_pane
= self
._mgr
.GetPane("settings").Float().Show()
480 if floating_pane
.floating_pos
== wx
.DefaultPosition
:
481 floating_pane
.FloatingPosition(self
.GetStartPosition())
486 def OnGradient(self
, event
):
490 if event
.GetId() == ID_NoGradient
:
491 gradient
= wx
.aui
.AUI_GRADIENT_NONE
492 elif event
.GetId() == ID_VerticalGradient
:
493 gradient
= wx
.aui
.AUI_GRADIENT_VERTICAL
494 elif event
.GetId() == ID_HorizontalGradient
:
495 gradient
= wx
.aui
.AUI_GRADIENT_HORIZONTAL
497 self
._mgr
.GetArtProvider().SetMetric(wx
.aui
.AUI_ART_GRADIENT_TYPE
, gradient
)
501 def OnManagerFlag(self
, event
):
506 if eid
in [ ID_TransparentHint
, ID_VenetianBlindsHint
, ID_RectangleHint
, ID_NoHint
]:
507 flags
= self
._mgr
.GetFlags()
508 flags
&= ~wx
.aui
.AUI_MGR_TRANSPARENT_HINT
509 flags
&= ~wx
.aui
.AUI_MGR_VENETIAN_BLINDS_HINT
510 flags
&= ~wx
.aui
.AUI_MGR_RECTANGLE_HINT
511 self
._mgr
.SetFlags(flags
)
513 if eid
== ID_AllowFloating
:
514 flag
= wx
.aui
.AUI_MGR_ALLOW_FLOATING
515 elif eid
== ID_TransparentDrag
:
516 flag
= wx
.aui
.AUI_MGR_TRANSPARENT_DRAG
517 elif eid
== ID_HintFade
:
518 flag
= wx
.aui
.AUI_MGR_HINT_FADE
519 elif eid
== ID_NoVenetianFade
:
520 flag
= wx
.aui
.AUI_MGR_NO_VENETIAN_BLINDS_FADE
521 elif eid
== ID_AllowActivePane
:
522 flag
= wx
.aui
.AUI_MGR_ALLOW_ACTIVE_PANE
523 elif eid
== ID_TransparentHint
:
524 flag
= wx
.aui
.AUI_MGR_TRANSPARENT_HINT
525 elif eid
== ID_VenetianBlindsHint
:
526 flag
= wx
.aui
.AUI_MGR_VENETIAN_BLINDS_HINT
527 elif eid
== ID_RectangleHint
:
528 flag
= wx
.aui
.AUI_MGR_RECTANGLE_HINT
530 self
._mgr
.SetFlags(self
._mgr
.GetFlags() ^ flag
)
533 def OnUpdateUI(self
, event
):
535 flags
= self
._mgr
.GetFlags()
538 if eid
== ID_NoGradient
:
539 event
.Check(self
._mgr
.GetArtProvider().GetMetric(wx
.aui
.AUI_ART_GRADIENT_TYPE
) == wx
.aui
.AUI_GRADIENT_NONE
)
541 elif eid
== ID_VerticalGradient
:
542 event
.Check(self
._mgr
.GetArtProvider().GetMetric(wx
.aui
.AUI_ART_GRADIENT_TYPE
) == wx
.aui
.AUI_GRADIENT_VERTICAL
)
544 elif eid
== ID_HorizontalGradient
:
545 event
.Check(self
._mgr
.GetArtProvider().GetMetric(wx
.aui
.AUI_ART_GRADIENT_TYPE
) == wx
.aui
.AUI_GRADIENT_HORIZONTAL
)
547 elif eid
== ID_AllowFloating
:
548 event
.Check((flags
& wx
.aui
.AUI_MGR_ALLOW_FLOATING
) != 0)
550 elif eid
== ID_TransparentDrag
:
551 event
.Check((flags
& wx
.aui
.AUI_MGR_TRANSPARENT_DRAG
) != 0)
553 elif eid
== ID_TransparentHint
:
554 event
.Check((flags
& wx
.aui
.AUI_MGR_TRANSPARENT_HINT
) != 0)
556 elif eid
== ID_VenetianBlindsHint
:
557 event
.Check((flags
& wx
.aui
.AUI_MGR_VENETIAN_BLINDS_HINT
) != 0)
559 elif eid
== ID_RectangleHint
:
560 event
.Check((flags
& wx
.aui
.AUI_MGR_RECTANGLE_HINT
) != 0)
562 elif eid
== ID_NoHint
:
563 event
.Check(((wx
.aui
.AUI_MGR_TRANSPARENT_HINT |
564 wx
.aui
.AUI_MGR_VENETIAN_BLINDS_HINT |
565 wx
.aui
.AUI_MGR_RECTANGLE_HINT
) & flags
) == 0)
567 elif eid
== ID_HintFade
:
568 event
.Check((flags
& wx
.aui
.AUI_MGR_HINT_FADE
) != 0);
570 elif eid
== ID_NoVenetianFade
:
571 event
.Check((flags
& wx
.aui
.AUI_MGR_NO_VENETIAN_BLINDS_FADE
) != 0);
576 def OnCreatePerspective(self
, event
):
578 dlg
= wx
.TextEntryDialog(self
, "Enter a name for the new perspective:", "AUI Test")
580 dlg
.SetValue(("Perspective %d")%(len(self
._perspectives
)+1))
581 if dlg
.ShowModal() != wx
.ID_OK
:
584 if len(self
._perspectives
) == 0:
585 self
._perspectives
_menu
.AppendSeparator()
587 self
._perspectives
_menu
.Append(ID_FirstPerspective
+ len(self
._perspectives
), dlg
.GetValue())
588 self
._perspectives
.append(self
._mgr
.SavePerspective())
591 def OnCopyPerspective(self
, event
):
593 s
= self
._mgr
.SavePerspective()
595 if wx
.TheClipboard
.Open():
597 wx
.TheClipboard
.SetData(wx
.TextDataObject(s
))
598 wx
.TheClipboard
.Close()
600 def OnRestorePerspective(self
, event
):
602 self
._mgr
.LoadPerspective(self
._perspectives
[event
.GetId() - ID_FirstPerspective
])
605 def GetStartPosition(self
):
609 pt
= self
.ClientToScreen(wx
.Point(0, 0))
611 return wx
.Point(pt
.x
+ x
, pt
.y
+ x
)
614 def OnCreateTree(self
, event
):
616 self
._mgr
.AddPane(self
.CreateTreeCtrl(), wx
.aui
.AuiPaneInfo().
617 Name("Test").Caption("Tree Control").
618 Float().FloatingPosition(self
.GetStartPosition()).
619 FloatingSize(wx
.Size(150, 300)))
623 def OnCreateGrid(self
, event
):
625 self
._mgr
.AddPane(self
.CreateGrid(), wx
.aui
.AuiPaneInfo().
626 Name("Test").Caption("Grid").
627 Float().FloatingPosition(self
.GetStartPosition()).
628 FloatingSize(wx
.Size(300, 200)))
632 def OnCreateHTML(self
, event
):
634 self
._mgr
.AddPane(self
.CreateHTMLCtrl(), wx
.aui
.AuiPaneInfo().
635 Name("Test").Caption("HTML Content").
636 Float().FloatingPosition(self
.GetStartPosition()).
637 FloatingSize(wx
.Size(300, 200)))
641 def OnCreateText(self
, event
):
643 self
._mgr
.AddPane(self
.CreateTextCtrl(), wx
.aui
.AuiPaneInfo().
644 Name("Test").Caption("Text Control").
645 Float().FloatingPosition(self
.GetStartPosition()))
649 def OnCreateSizeReport(self
, event
):
651 self
._mgr
.AddPane(self
.CreateSizeReportCtrl(), wx
.aui
.AuiPaneInfo().
652 Name("Test").Caption("Client Size Reporter").
653 Float().FloatingPosition(self
.GetStartPosition()))
657 def OnChangeContentPane(self
, event
):
659 self
._mgr
.GetPane("grid_content").Show(event
.GetId() == ID_GridContent
)
660 self
._mgr
.GetPane("text_content").Show(event
.GetId() == ID_TextContent
)
661 self
._mgr
.GetPane("tree_content").Show(event
.GetId() == ID_TreeContent
)
662 self
._mgr
.GetPane("sizereport_content").Show(event
.GetId() == ID_SizeReportContent
)
663 self
._mgr
.GetPane("html_content").Show(event
.GetId() == ID_HTMLContent
)
667 def CreateTextCtrl(self
):
669 text
= ("This is text box %d")%(self
.n
+ 1)
671 return wx
.TextCtrl(self
,-1, text
, wx
.Point(0, 0), wx
.Size(150, 90),
672 wx
.NO_BORDER | wx
.TE_MULTILINE
)
676 def CreateGrid(self
):
678 grid
= wx
.grid
.Grid(self
, -1, wx
.Point(0, 0), wx
.Size(150, 250),
679 wx
.NO_BORDER | wx
.WANTS_CHARS
)
681 grid
.CreateGrid(50, 20)
686 def CreateTreeCtrl(self
):
688 tree
= wx
.TreeCtrl(self
, -1, wx
.Point(0, 0), wx
.Size(160, 250),
689 wx
.TR_DEFAULT_STYLE | wx
.NO_BORDER
)
691 root
= tree
.AddRoot("AUI Project")
694 imglist
= wx
.ImageList(16, 16, True, 2)
695 imglist
.Add(wx
.ArtProvider_GetBitmap(wx
.ART_FOLDER
, wx
.ART_OTHER
, wx
.Size(16,16)))
696 imglist
.Add(wx
.ArtProvider_GetBitmap(wx
.ART_NORMAL_FILE
, wx
.ART_OTHER
, wx
.Size(16,16)))
697 tree
.AssignImageList(imglist
)
699 items
.append(tree
.AppendItem(root
, "Item 1", 0))
700 items
.append(tree
.AppendItem(root
, "Item 2", 0))
701 items
.append(tree
.AppendItem(root
, "Item 3", 0))
702 items
.append(tree
.AppendItem(root
, "Item 4", 0))
703 items
.append(tree
.AppendItem(root
, "Item 5", 0))
705 for ii
in xrange(len(items
)):
708 tree
.AppendItem(id, "Subitem 1", 1)
709 tree
.AppendItem(id, "Subitem 2", 1)
710 tree
.AppendItem(id, "Subitem 3", 1)
711 tree
.AppendItem(id, "Subitem 4", 1)
712 tree
.AppendItem(id, "Subitem 5", 1)
719 def CreateSizeReportCtrl(self
, width
=80, height
=80):
721 ctrl
= SizeReportCtrl(self
, -1, wx
.DefaultPosition
,
722 wx
.Size(width
, height
), self
._mgr
)
726 def CreateHTMLCtrl(self
):
727 ctrl
= wx
.html
.HtmlWindow(self
, -1, wx
.DefaultPosition
, wx
.Size(400, 300))
728 if "gtk2" in wx
.PlatformInfo
:
729 ctrl
.SetStandardFonts()
730 ctrl
.SetPage(self
.GetIntroText())
734 def GetIntroText(self
):
738 # -- wx.SizeReportCtrl --
739 # (a utility control that always reports it's client size)
741 class SizeReportCtrl(wx
.PyControl
):
743 def __init__(self
, parent
, id=wx
.ID_ANY
, pos
=wx
.DefaultPosition
,
744 size
=wx
.DefaultSize
, mgr
=None):
746 wx
.PyControl
.__init
__(self
, parent
, id, pos
, size
, wx
.NO_BORDER
)
750 self
.Bind(wx
.EVT_PAINT
, self
.OnPaint
)
751 self
.Bind(wx
.EVT_SIZE
, self
.OnSize
)
752 self
.Bind(wx
.EVT_ERASE_BACKGROUND
, self
.OnEraseBackground
)
755 def OnPaint(self
, event
):
757 dc
= wx
.PaintDC(self
)
759 size
= self
.GetClientSize()
760 s
= ("Size: %d x %d")%(size
.x
, size
.y
)
762 dc
.SetFont(wx
.NORMAL_FONT
)
763 w
, height
= dc
.GetTextExtent(s
)
765 dc
.SetBrush(wx
.WHITE_BRUSH
)
766 dc
.SetPen(wx
.WHITE_PEN
)
767 dc
.DrawRectangle(0, 0, size
.x
, size
.y
)
768 dc
.SetPen(wx
.LIGHT_GREY_PEN
)
769 dc
.DrawLine(0, 0, size
.x
, size
.y
)
770 dc
.DrawLine(0, size
.y
, size
.x
, 0)
771 dc
.DrawText(s
, (size
.x
-w
)/2, ((size
.y
-(height
*5))/2))
775 pi
= self
._mgr
.GetPane(self
)
777 s
= ("Layer: %d")%pi
.dock_layer
778 w
, h
= dc
.GetTextExtent(s
)
779 dc
.DrawText(s
, (size
.x
-w
)/2, ((size
.y
-(height
*5))/2)+(height
*1))
781 s
= ("Dock: %d Row: %d")%(pi
.dock_direction
, pi
.dock_row
)
782 w
, h
= dc
.GetTextExtent(s
)
783 dc
.DrawText(s
, (size
.x
-w
)/2, ((size
.y
-(height
*5))/2)+(height
*2))
785 s
= ("Position: %d")%pi
.dock_pos
786 w
, h
= dc
.GetTextExtent(s
)
787 dc
.DrawText(s
, (size
.x
-w
)/2, ((size
.y
-(height
*5))/2)+(height
*3))
789 s
= ("Proportion: %d")%pi
.dock_proportion
790 w
, h
= dc
.GetTextExtent(s
)
791 dc
.DrawText(s
, (size
.x
-w
)/2, ((size
.y
-(height
*5))/2)+(height
*4))
794 def OnEraseBackground(self
, event
):
795 # intentionally empty
799 def OnSize(self
, event
):
805 ID_PaneBorderSize
= wx
.ID_HIGHEST
+ 1
806 ID_SashSize
= ID_PaneBorderSize
+ 1
807 ID_CaptionSize
= ID_PaneBorderSize
+ 2
808 ID_BackgroundColor
= ID_PaneBorderSize
+ 3
809 ID_SashColor
= ID_PaneBorderSize
+ 4
810 ID_InactiveCaptionColor
= ID_PaneBorderSize
+ 5
811 ID_InactiveCaptionGradientColor
= ID_PaneBorderSize
+ 6
812 ID_InactiveCaptionTextColor
= ID_PaneBorderSize
+ 7
813 ID_ActiveCaptionColor
= ID_PaneBorderSize
+ 8
814 ID_ActiveCaptionGradientColor
= ID_PaneBorderSize
+ 9
815 ID_ActiveCaptionTextColor
= ID_PaneBorderSize
+ 10
816 ID_BorderColor
= ID_PaneBorderSize
+ 11
817 ID_GripperColor
= ID_PaneBorderSize
+ 12
819 class SettingsPanel(wx
.Panel
):
821 def __init__(self
, parent
, frame
):
823 wx
.Panel
.__init
__(self
, parent
, wx
.ID_ANY
, wx
.DefaultPosition
,
828 vert
= wx
.BoxSizer(wx
.VERTICAL
)
830 s1
= wx
.BoxSizer(wx
.HORIZONTAL
)
831 self
._border
_size
= wx
.SpinCtrl(self
, ID_PaneBorderSize
, "", wx
.DefaultPosition
, wx
.Size(50,20))
832 s1
.Add((1, 1), 1, wx
.EXPAND
)
833 s1
.Add(wx
.StaticText(self
, -1, "Pane Border Size:"))
834 s1
.Add(self
._border
_size
)
835 s1
.Add((1, 1), 1, wx
.EXPAND
)
836 s1
.SetItemMinSize(1, (180, 20))
837 #vert.Add(s1, 0, wx.EXPAND | wxLEFT | wxBOTTOM, 5)
839 s2
= wx
.BoxSizer(wx
.HORIZONTAL
)
840 self
._sash
_size
= wx
.SpinCtrl(self
, ID_SashSize
, "", wx
.DefaultPosition
, wx
.Size(50,20))
841 s2
.Add((1, 1), 1, wx
.EXPAND
)
842 s2
.Add(wx
.StaticText(self
, -1, "Sash Size:"))
843 s2
.Add(self
._sash
_size
)
844 s2
.Add((1, 1), 1, wx
.EXPAND
)
845 s2
.SetItemMinSize(1, (180, 20))
846 #vert.Add(s2, 0, wx.EXPAND | wxLEFT | wxBOTTOM, 5)
848 s3
= wx
.BoxSizer(wx
.HORIZONTAL
)
849 self
._caption
_size
= wx
.SpinCtrl(self
, ID_CaptionSize
, "", wx
.DefaultPosition
, wx
.Size(50,20))
850 s3
.Add((1, 1), 1, wx
.EXPAND
)
851 s3
.Add(wx
.StaticText(self
, -1, "Caption Size:"))
852 s3
.Add(self
._caption
_size
)
853 s3
.Add((1, 1), 1, wx
.EXPAND
)
854 s3
.SetItemMinSize(1, (180, 20))
855 #vert.Add(s3, 0, wx.EXPAND | wxLEFT | wxBOTTOM, 5)
857 #vert.Add(1, 1, 1, wx.EXPAND)
859 b
= self
.CreateColorBitmap(wx
.BLACK
)
861 s4
= wx
.BoxSizer(wx
.HORIZONTAL
)
862 self
._background
_color
= wx
.BitmapButton(self
, ID_BackgroundColor
, b
, wx
.DefaultPosition
, wx
.Size(50,25))
863 s4
.Add((1, 1), 1, wx
.EXPAND
)
864 s4
.Add(wx
.StaticText(self
, -1, "Background Color:"))
865 s4
.Add(self
._background
_color
)
866 s4
.Add((1, 1), 1, wx
.EXPAND
)
867 s4
.SetItemMinSize(1, (180, 20))
869 s5
= wx
.BoxSizer(wx
.HORIZONTAL
)
870 self
._sash
_color
= wx
.BitmapButton(self
, ID_SashColor
, b
, wx
.DefaultPosition
, wx
.Size(50,25))
871 s5
.Add((1, 1), 1, wx
.EXPAND
)
872 s5
.Add(wx
.StaticText(self
, -1, "Sash Color:"))
873 s5
.Add(self
._sash
_color
)
874 s5
.Add((1, 1), 1, wx
.EXPAND
)
875 s5
.SetItemMinSize(1, (180, 20))
877 s6
= wx
.BoxSizer(wx
.HORIZONTAL
)
878 self
._inactive
_caption
_color
= wx
.BitmapButton(self
, ID_InactiveCaptionColor
, b
,
879 wx
.DefaultPosition
, wx
.Size(50,25))
880 s6
.Add((1, 1), 1, wx
.EXPAND
)
881 s6
.Add(wx
.StaticText(self
, -1, "Normal Caption:"))
882 s6
.Add(self
._inactive
_caption
_color
)
883 s6
.Add((1, 1), 1, wx
.EXPAND
)
884 s6
.SetItemMinSize(1, (180, 20))
886 s7
= wx
.BoxSizer(wx
.HORIZONTAL
)
887 self
._inactive
_caption
_gradient
_color
= wx
.BitmapButton(self
, ID_InactiveCaptionGradientColor
,
888 b
, wx
.DefaultPosition
, wx
.Size(50,25))
889 s7
.Add((1, 1), 1, wx
.EXPAND
)
890 s7
.Add(wx
.StaticText(self
, -1, "Normal Caption Gradient:"))
891 s7
.Add(self
._inactive
_caption
_gradient
_color
)
892 s7
.Add((1, 1), 1, wx
.EXPAND
)
893 s7
.SetItemMinSize(1, (180, 20))
895 s8
= wx
.BoxSizer(wx
.HORIZONTAL
)
896 self
._inactive
_caption
_text
_color
= wx
.BitmapButton(self
, ID_InactiveCaptionTextColor
, b
,
897 wx
.DefaultPosition
, wx
.Size(50,25))
898 s8
.Add((1, 1), 1, wx
.EXPAND
)
899 s8
.Add(wx
.StaticText(self
, -1, "Normal Caption Text:"))
900 s8
.Add(self
._inactive
_caption
_text
_color
)
901 s8
.Add((1, 1), 1, wx
.EXPAND
)
902 s8
.SetItemMinSize(1, (180, 20))
904 s9
= wx
.BoxSizer(wx
.HORIZONTAL
)
905 self
._active
_caption
_color
= wx
.BitmapButton(self
, ID_ActiveCaptionColor
, b
,
906 wx
.DefaultPosition
, wx
.Size(50,25))
907 s9
.Add((1, 1), 1, wx
.EXPAND
)
908 s9
.Add(wx
.StaticText(self
, -1, "Active Caption:"))
909 s9
.Add(self
._active
_caption
_color
)
910 s9
.Add((1, 1), 1, wx
.EXPAND
)
911 s9
.SetItemMinSize(1, (180, 20))
913 s10
= wx
.BoxSizer(wx
.HORIZONTAL
)
914 self
._active
_caption
_gradient
_color
= wx
.BitmapButton(self
, ID_ActiveCaptionGradientColor
,
915 b
, wx
.DefaultPosition
, wx
.Size(50,25))
916 s10
.Add((1, 1), 1, wx
.EXPAND
)
917 s10
.Add(wx
.StaticText(self
, -1, "Active Caption Gradient:"))
918 s10
.Add(self
._active
_caption
_gradient
_color
)
919 s10
.Add((1, 1), 1, wx
.EXPAND
)
920 s10
.SetItemMinSize(1, (180, 20))
922 s11
= wx
.BoxSizer(wx
.HORIZONTAL
)
923 self
._active
_caption
_text
_color
= wx
.BitmapButton(self
, ID_ActiveCaptionTextColor
,
924 b
, wx
.DefaultPosition
, wx
.Size(50,25))
925 s11
.Add((1, 1), 1, wx
.EXPAND
)
926 s11
.Add(wx
.StaticText(self
, -1, "Active Caption Text:"))
927 s11
.Add(self
._active
_caption
_text
_color
)
928 s11
.Add((1, 1), 1, wx
.EXPAND
)
929 s11
.SetItemMinSize(1, (180, 20))
931 s12
= wx
.BoxSizer(wx
.HORIZONTAL
)
932 self
._border
_color
= wx
.BitmapButton(self
, ID_BorderColor
, b
, wx
.DefaultPosition
,
934 s12
.Add((1, 1), 1, wx
.EXPAND
)
935 s12
.Add(wx
.StaticText(self
, -1, "Border Color:"))
936 s12
.Add(self
._border
_color
)
937 s12
.Add((1, 1), 1, wx
.EXPAND
)
938 s12
.SetItemMinSize(1, (180, 20))
940 s13
= wx
.BoxSizer(wx
.HORIZONTAL
)
941 self
._gripper
_color
= wx
.BitmapButton(self
, ID_GripperColor
, b
, wx
.DefaultPosition
,
943 s13
.Add((1, 1), 1, wx
.EXPAND
)
944 s13
.Add(wx
.StaticText(self
, -1, "Gripper Color:"))
945 s13
.Add(self
._gripper
_color
)
946 s13
.Add((1, 1), 1, wx
.EXPAND
)
947 s13
.SetItemMinSize(1, (180, 20))
949 grid_sizer
= wx
.GridSizer(0, 2)
950 grid_sizer
.SetHGap(5)
957 grid_sizer
.Add((1, 1))
966 cont_sizer
= wx
.BoxSizer(wx
.VERTICAL
)
967 cont_sizer
.Add(grid_sizer
, 1, wx
.EXPAND | wx
.ALL
, 5)
968 self
.SetSizer(cont_sizer
)
969 self
.GetSizer().SetSizeHints(self
)
971 self
._border
_size
.SetValue(frame
.GetDockArt().GetMetric(wx
.aui
.AUI_ART_PANE_BORDER_SIZE
))
972 self
._sash
_size
.SetValue(frame
.GetDockArt().GetMetric(wx
.aui
.AUI_ART_SASH_SIZE
))
973 self
._caption
_size
.SetValue(frame
.GetDockArt().GetMetric(wx
.aui
.AUI_ART_CAPTION_SIZE
))
977 self
.Bind(wx
.EVT_SPINCTRL
, self
.OnPaneBorderSize
, id=ID_PaneBorderSize
)
978 self
.Bind(wx
.EVT_SPINCTRL
, self
.OnSashSize
, id=ID_SashSize
)
979 self
.Bind(wx
.EVT_SPINCTRL
, self
.OnCaptionSize
, id=ID_CaptionSize
)
980 self
.Bind(wx
.EVT_BUTTON
, self
.OnSetColor
, id=ID_BackgroundColor
)
981 self
.Bind(wx
.EVT_BUTTON
, self
.OnSetColor
, id=ID_SashColor
)
982 self
.Bind(wx
.EVT_BUTTON
, self
.OnSetColor
, id=ID_InactiveCaptionColor
)
983 self
.Bind(wx
.EVT_BUTTON
, self
.OnSetColor
, id=ID_InactiveCaptionGradientColor
)
984 self
.Bind(wx
.EVT_BUTTON
, self
.OnSetColor
, id=ID_InactiveCaptionTextColor
)
985 self
.Bind(wx
.EVT_BUTTON
, self
.OnSetColor
, id=ID_ActiveCaptionColor
)
986 self
.Bind(wx
.EVT_BUTTON
, self
.OnSetColor
, id=ID_ActiveCaptionGradientColor
)
987 self
.Bind(wx
.EVT_BUTTON
, self
.OnSetColor
, id=ID_ActiveCaptionTextColor
)
988 self
.Bind(wx
.EVT_BUTTON
, self
.OnSetColor
, id=ID_BorderColor
)
989 self
.Bind(wx
.EVT_BUTTON
, self
.OnSetColor
, id=ID_GripperColor
)
992 def CreateColorBitmap(self
, c
):
993 image
= wx
.EmptyImage(25, 14)
998 if x
== 0 or x
== 24 or y
== 0 or y
== 13:
1001 image
.SetRGB(x
, y
, pixcol
.Red(), pixcol
.Green(), pixcol
.Blue())
1003 return image
.ConvertToBitmap()
1006 def UpdateColors(self
):
1008 bk
= self
._frame
.GetDockArt().GetColour(wx
.aui
.AUI_ART_BACKGROUND_COLOUR
)
1009 self
._background
_color
.SetBitmapLabel(self
.CreateColorBitmap(bk
))
1011 cap
= self
._frame
.GetDockArt().GetColour(wx
.aui
.AUI_ART_INACTIVE_CAPTION_COLOUR
)
1012 self
._inactive
_caption
_color
.SetBitmapLabel(self
.CreateColorBitmap(cap
))
1014 capgrad
= self
._frame
.GetDockArt().GetColour(wx
.aui
.AUI_ART_INACTIVE_CAPTION_GRADIENT_COLOUR
)
1015 self
._inactive
_caption
_gradient
_color
.SetBitmapLabel(self
.CreateColorBitmap(capgrad
))
1017 captxt
= self
._frame
.GetDockArt().GetColour(wx
.aui
.AUI_ART_INACTIVE_CAPTION_TEXT_COLOUR
)
1018 self
._inactive
_caption
_text
_color
.SetBitmapLabel(self
.CreateColorBitmap(captxt
))
1020 acap
= self
._frame
.GetDockArt().GetColour(wx
.aui
.AUI_ART_ACTIVE_CAPTION_COLOUR
)
1021 self
._active
_caption
_color
.SetBitmapLabel(self
.CreateColorBitmap(acap
))
1023 acapgrad
= self
._frame
.GetDockArt().GetColour(wx
.aui
.AUI_ART_ACTIVE_CAPTION_GRADIENT_COLOUR
)
1024 self
._active
_caption
_gradient
_color
.SetBitmapLabel(self
.CreateColorBitmap(acapgrad
))
1026 acaptxt
= self
._frame
.GetDockArt().GetColour(wx
.aui
.AUI_ART_ACTIVE_CAPTION_TEXT_COLOUR
)
1027 self
._active
_caption
_text
_color
.SetBitmapLabel(self
.CreateColorBitmap(acaptxt
))
1029 sash
= self
._frame
.GetDockArt().GetColour(wx
.aui
.AUI_ART_SASH_COLOUR
)
1030 self
._sash
_color
.SetBitmapLabel(self
.CreateColorBitmap(sash
))
1032 border
= self
._frame
.GetDockArt().GetColour(wx
.aui
.AUI_ART_BORDER_COLOUR
)
1033 self
._border
_color
.SetBitmapLabel(self
.CreateColorBitmap(border
))
1035 gripper
= self
._frame
.GetDockArt().GetColour(wx
.aui
.AUI_ART_GRIPPER_COLOUR
)
1036 self
._gripper
_color
.SetBitmapLabel(self
.CreateColorBitmap(gripper
))
1039 def OnPaneBorderSize(self
, event
):
1041 self
._frame
.GetDockArt().SetMetric(wx
.aui
.AUI_ART_PANE_BORDER_SIZE
,
1043 self
._frame
.DoUpdate()
1046 def OnSashSize(self
, event
):
1048 self
._frame
.GetDockArt().SetMetric(wx
.aui
.AUI_ART_SASH_SIZE
,
1050 self
._frame
.DoUpdate()
1053 def OnCaptionSize(self
, event
):
1055 self
._frame
.GetDockArt().SetMetric(wx
.aui
.AUI_ART_CAPTION_SIZE
,
1057 self
._frame
.DoUpdate()
1060 def OnSetColor(self
, event
):
1062 dlg
= wx
.ColourDialog(self
._frame
)
1064 dlg
.SetTitle("Color Picker")
1066 if dlg
.ShowModal() != wx
.ID_OK
:
1070 if event
.GetId() == ID_BackgroundColor
:
1071 var
= wx
.aui
.AUI_ART_BACKGROUND_COLOUR
1072 elif event
.GetId() == ID_SashColor
:
1073 var
= wx
.aui
.AUI_ART_SASH_COLOUR
1074 elif event
.GetId() == ID_InactiveCaptionColor
:
1075 var
= wx
.aui
.AUI_ART_INACTIVE_CAPTION_COLOUR
1076 elif event
.GetId() == ID_InactiveCaptionGradientColor
:
1077 var
= wx
.aui
.AUI_ART_INACTIVE_CAPTION_GRADIENT_COLOUR
1078 elif event
.GetId() == ID_InactiveCaptionTextColor
:
1079 var
= wx
.aui
.AUI_ART_INACTIVE_CAPTION_TEXT_COLOUR
1080 elif event
.GetId() == ID_ActiveCaptionColor
:
1081 var
= wx
.aui
.AUI_ART_ACTIVE_CAPTION_COLOUR
1082 elif event
.GetId() == ID_ActiveCaptionGradientColor
:
1083 var
= wx
.aui
.AUI_ART_ACTIVE_CAPTION_GRADIENT_COLOUR
1084 elif event
.GetId() == ID_ActiveCaptionTextColor
:
1085 var
= wx
.aui
.AUI_ART_ACTIVE_CAPTION_TEXT_COLOUR
1086 elif event
.GetId() == ID_BorderColor
:
1087 var
= wx
.aui
.AUI_ART_BORDER_COLOUR
1088 elif event
.GetId() == ID_GripperColor
:
1089 var
= wx
.aui
.AUI_ART_GRIPPER_COLOUR
1093 self
._frame
.GetDockArt().SetColor(var
, dlg
.GetColourData().GetColour())
1094 self
._frame
.DoUpdate()
1099 #----------------------------------------------------------------------
1101 class TestPanel(wx
.Panel
):
1102 def __init__(self
, parent
, log
):
1104 wx
.Panel
.__init
__(self
, parent
, -1)
1105 b
= wx
.Button(self
, -1, "Show the wx.aui Demo Frame", (50,50))
1106 self
.Bind(wx
.EVT_BUTTON
, self
.OnButton
, b
)
1108 def OnButton(self
, evt
):
1109 frame
= PyAUIFrame(self
, wx
.ID_ANY
, "wx.aui wxPython Demo", size
=(750, 590))
1112 #----------------------------------------------------------------------
1114 def runTest(frame
, nb
, log
):
1115 win
= TestPanel(nb
, log
)
1118 #----------------------------------------------------------------------
1124 <h3>wx.aui, the Advanced User Interface module</h3>
1126 <br/><b>Overview</b><br/>
1128 <p>wx.aui is an Advanced User Interface library for the wxWidgets toolkit
1129 that allows developers to create high-quality, cross-platform user
1130 interfaces quickly and easily.</p>
1132 <p><b>Features</b></p>
1134 <p>With wx.aui developers can create application frameworks with:</p>
1137 <li>Native, dockable floating frames</li>
1138 <li>Perspective saving and loading</li>
1139 <li>Native toolbars incorporating real-time, "spring-loaded" dragging</li>
1140 <li>Customizable floating/docking behavior</li>
1141 <li>Completely customizable look-and-feel</li>
1142 <li>Optional transparent window effects (while dragging or docking)</li>
1151 if __name__
== '__main__':
1154 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])