def __init__(self, frame): aui.AuiToolBar.__init__(self, frame) # prepare a few custom overflow elements for the toolbars' overflow buttons prepend_items, append_items = [], [] item = aui.AuiToolBarItem() item.SetKind(wx.ITEM_SEPARATOR) append_items.append(item) item = aui.AuiToolBarItem() item.SetKind(wx.ITEM_NORMAL) item.SetId(ID_CustomizeToolbar) item.SetLabel("Customize...") append_items.append(item) self._frame = frame # DEBUG If we attach to frame it won't be detachable, and overlaps # If self, buttons are not shown self.tb = aui.AuiToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, agwStyle=aui.AUI_TB_DEFAULT_STYLE | aui.AUI_TB_OVERFLOW) self.tb.SetToolBitmapSize(wx.Size(16, 16)) self._buttons = [] self._search_handlers = {} self._current_description = None self.tb.SetCustomOverflowItems(prepend_items, append_items) self.tb.Realize()
def test_lib_agw_aui_ToolbarCtor(self): tb = aui.AuiToolBar(self.frame, -1, wx.DefaultPosition, wx.DefaultSize, agwStyle=aui.AUI_TB_OVERFLOW | aui.AUI_TB_VERT_TEXT) tb_bmp1 = wx.ArtProvider.GetBitmap(wx.ART_QUESTION, wx.ART_OTHER, wx.Size(16, 16)) tb.AddSimpleTool(-1, "Test", tb_bmp1) tb.AddSimpleTool(-1, "Check 1", tb_bmp1, "Check 1", aui.ITEM_CHECK) tb.AddSimpleTool(-1, "Radio 1", tb_bmp1, "Radio 1", aui.ITEM_RADIO) tb.AddSeparator() # prepare a few custom overflow elements for the toolbars' overflow buttons prepend_items, append_items = [], [] item = aui.AuiToolBarItem() item.SetKind(wx.ITEM_SEPARATOR) append_items.append(item) item = aui.AuiToolBarItem() item.SetKind(wx.ITEM_NORMAL) item.SetId(-1) item.SetLabel("Customize...") append_items.append(item) tb.SetCustomOverflowItems(prepend_items, append_items) tb.Realize()
def testToolbar(self): #### More testing prepend_items, append_items = [], [] item = aui.AuiToolBarItem() item.SetKind(wx.ITEM_SEPARATOR) append_items.append(item) item = aui.AuiToolBarItem() item.SetKind(wx.ITEM_NORMAL) item.SetId(ID_CustomizeToolbar) item.SetLabel("Customize...") append_items.append(item) tb3 = aui.AuiToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, agwStyle=aui.AUI_TB_DEFAULT_STYLE | aui.AUI_TB_OVERFLOW) tb3.SetToolBitmapSize(wx.Size(16, 16)) tb3_bmp1 = wx.ArtProvider.GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, wx.Size(16, 16)) tb3.AddSimpleTool(ID_SampleItem + 16, "Check 1", tb3_bmp1, "Check 1", aui.ITEM_CHECK) tb3.AddSimpleTool(ID_SampleItem + 17, "Check 2", tb3_bmp1, "Check 2", aui.ITEM_CHECK) tb3.AddSimpleTool(ID_SampleItem + 18, "Check 3", tb3_bmp1, "Check 3", aui.ITEM_CHECK) tb3.AddSimpleTool(ID_SampleItem + 19, "Check 4", tb3_bmp1, "Check 4", aui.ITEM_CHECK) tb3.AddSeparator() tb3.AddSimpleTool(ID_SampleItem + 20, "Radio 1", tb3_bmp1, "Radio 1", aui.ITEM_RADIO) tb3.AddSimpleTool(ID_SampleItem + 21, "Radio 2", tb3_bmp1, "Radio 2", aui.ITEM_RADIO) tb3.AddSimpleTool(ID_SampleItem + 22, "Radio 3", tb3_bmp1, "Radio 3", aui.ITEM_RADIO) tb3.AddSeparator() tb3.AddSimpleTool(ID_SampleItem + 23, "Radio 1 (Group 2)", tb3_bmp1, "Radio 1 (Group 2)", aui.ITEM_RADIO) tb3.AddSimpleTool(ID_SampleItem + 24, "Radio 2 (Group 2)", tb3_bmp1, "Radio 2 (Group 2)", aui.ITEM_RADIO) tb3.AddSimpleTool(ID_SampleItem + 25, "Radio 3 (Group 2)", tb3_bmp1, "Radio 3 (Group 2)", aui.ITEM_RADIO) tb3.SetCustomOverflowItems(prepend_items, append_items) tb3.Realize() return tb3
def BuildPanes(self): # min size for the frame itself isn't completely done. # see the end up AuiManager.Update() for the test # code. For now, just hard code a frame minimum size self.SetMinSize(wx.Size(400, 300)) # prepare a few custom overflow elements for the toolbars' overflow buttons prepend_items, append_items = [], [] item = aui.AuiToolBarItem() item.SetKind(wx.ITEM_SEPARATOR) append_items.append(item) item = aui.AuiToolBarItem() item.SetKind(wx.ITEM_NORMAL) # item.SetId(ID_CustomizeToolbar) item.SetLabel("Customize...") append_items.append(item) # create some toolbars ID_SampleItem = wx.ID_ANY print '--------->', ID_SampleItem tb1 = aui.AuiToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, agwStyle=aui.AUI_TB_DEFAULT_STYLE | aui.AUI_TB_OVERFLOW) tb1.SetToolBitmapSize(wx.Size(48, 48)) tb1.AddSimpleTool(ID_SampleItem + 2, "Test", wx.ArtProvider.GetBitmap(wx.ART_GO_BACK)) tb1.AddSimpleTool(ID_SampleItem + 4, "Test", wx.ArtProvider.GetBitmap(wx.ART_GO_HOME)) tb1.AddSimpleTool(ID_SampleItem + 3, "Test", wx.ArtProvider.GetBitmap(wx.ART_GO_FORWARD)) tb1.AddSimpleTool(ID_SampleItem + 5, "Test", wx.ArtProvider.GetBitmap(wx.ART_MISSING_IMAGE)) tb1.AddSeparator() tb1.AddSimpleTool(tool_id=(ID_SampleItem + 1), label="bookmark", short_help_string="Bookmark", bitmap=wx.ArtProvider.GetBitmap(wx.ART_ADD_BOOKMARK)) tb1.SetCustomOverflowItems(prepend_items, append_items) tb1.Realize() tb2 = aui.AuiToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, agwStyle=aui.AUI_TB_DEFAULT_STYLE | aui.AUI_TB_OVERFLOW) tb2.SetToolBitmapSize(wx.Size(16, 16)) # tb2_bmp1 = wx.ArtProvider.GetBitmap(wx.ART_QUESTION, wx.ART_OTHER, wx.Size(16, 16)) imageUtil = ImageUtil() zoom = imageUtil.getBitmap(iconName='zoom') comments = imageUtil.getBitmap(iconName='comments') doublePage = imageUtil.getBitmap(iconName='double-page') fitbest = imageUtil.getBitmap(iconName='fitbest') fitheight = imageUtil.getBitmap(iconName='fitheight') gimpRotate180 = imageUtil.getBitmap(iconName='gimp-rotate-180') gimpRotate270 = imageUtil.getBitmap(iconName='gimp-rotate-270') gimpRotate90 = imageUtil.getBitmap(iconName='gimp-rotate-90') lens = imageUtil.getBitmap(iconName='lens') fitwidth = imageUtil.getBitmap(iconName='fitwidth') tb2.AddSimpleTool(ID_SampleItem + 6, "Test", zoom) tb2.AddSimpleTool(ID_SampleItem + 7, "Test", comments) tb2.AddSimpleTool(ID_SampleItem + 8, "Test", doublePage) tb2.AddSimpleTool(ID_SampleItem + 9, "Test", fitbest) tb2.AddSeparator() tb2.AddSimpleTool(ID_SampleItem + 10, "Test", fitheight) tb2.AddSimpleTool(ID_SampleItem + 11, "Test", gimpRotate180) tb2.AddSeparator() tb2.AddSimpleTool(ID_SampleItem + 12, "Test", lens) tb2.AddSimpleTool(ID_SampleItem + 13, "Test", fitwidth) tb2.AddSimpleTool(ID_SampleItem + 14, "Test", gimpRotate270) tb2.AddSimpleTool(ID_SampleItem + 15, "Test", gimpRotate90) tb2.SetCustomOverflowItems(prepend_items, append_items) tb2.Realize() # add the toolbars to the manager self._mgr.AddPane( tb1, aui.AuiPaneInfo().Name("tb1").Caption( "Big Toolbar").ToolbarPane().Top()) self._mgr.AddPane( tb2, aui.AuiPaneInfo().Name("tb2").Caption( "Toolbar 2").ToolbarPane().Top().Row(0)) # add a bunch of panes # self._mgr.AddPane(self.CreateSizeReportCtrl(), aui.AuiPaneInfo().Name("test1").Caption("Pane Caption").Top().MinimizeButton(True)) # self._mgr.AddPane(self.CreateSizeReportCtrl(), aui.AuiPaneInfo(). # Name("test2").Caption("Client Size Reporter"). # Bottom().Position(1).CloseButton(True).MaximizeButton(True). # MinimizeButton(True).CaptionVisible(True, left=True)) # self._mgr.AddPane(self.CreateSizeReportCtrl(), aui.AuiPaneInfo(). # Name("test3").Caption("Client Size Reporter"). # Bottom().CloseButton(True).MaximizeButton(True).MinimizeButton(True). # CaptionVisible(True, left=True)) self._mgr.AddPane( self.CreateSizeReportCtrl(), aui.AuiPaneInfo().Name("thumbnails").Caption("Thumbnails").Left(). LeftDockable(True).MinimizeButton(True).BestSize(200, 200)) self._mgr.AddPane( self.photoCtrl(), aui.AuiPaneInfo().Name("photo").Caption("Current page").Center(). LeftDockable(True).MinimizeButton(True).CloseButton(False)) # self._mgr.AddPane(self.CreateSizeReportCtrl(), aui.AuiPaneInfo(). # Name("test5").Caption("No Close Button").Right().CloseButton(False)) # # self._mgr.AddPane(self.CreateSizeReportCtrl(), aui.AuiPaneInfo(). # Name("test6").Caption("Client Size Reporter").Right().Row(1). # CloseButton(True).MaximizeButton(True).MinimizeButton(True)) # self._mgr.AddPane(self.CreateSizeReportCtrl(), aui.AuiPaneInfo(). # Name("test7").Caption("Client Size Reporter").Left().Layer(1). # CloseButton(True).MaximizeButton(True).MinimizeButton(True)) # self._mgr.AddPane(self.CreateTreeCtrl(), aui.AuiPaneInfo().Name("test8").Caption("Tree Pane"). # Left().Layer(1).Position(1).CloseButton(True).MaximizeButton(True). # MinimizeButton(True)) perspective_default = self._mgr.SavePerspective() # make some default perspectives perspective_all = self._mgr.SavePerspective() self._perspectives = [] self._perspectives.append(perspective_default) self._perspectives.append(perspective_all) all_panes = self._mgr.GetAllPanes() for pane in all_panes: if not pane.IsToolbar(): # pane.Hide() pane.Show() perspective_default = self._mgr.SavePerspective() self._perspectives = [] self._perspectives.append(perspective_default) self._perspectives.append(perspective_all) self._nb_perspectives = [] # "commit" all changes made to AuiManager self._mgr.Update()