def __init__(self, parent, id=wx.ID_ANY, title="", pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, log=None): wx.Frame.__init__(self, parent, id, title, pos, size, style) panel = wx.Panel(self) self._ribbon = RB.RibbonBar(panel, wx.ID_ANY) self._bitmap_creation_dc = wx.MemoryDC() self._colour_data = wx.ColourData() home = RB.RibbonPage(self._ribbon, wx.ID_ANY, "Examples", CreateBitmap("ribbon")) toolbar_panel = RB.RibbonPanel( home, wx.ID_ANY, "Toolbar", wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, agwStyle=RB.RIBBON_PANEL_NO_AUTO_MINIMISE) toolbar = RB.RibbonToolBar(toolbar_panel, ID_MAIN_TOOLBAR) toolbar.AddTool(wx.ID_ANY, CreateBitmap("align_left")) toolbar.AddTool(wx.ID_ANY, CreateBitmap("align_center")) toolbar.AddTool(wx.ID_ANY, CreateBitmap("align_right")) toolbar.AddSeparator() toolbar.AddHybridTool( wx.ID_NEW, wx.ArtProvider.GetBitmap(wx.ART_NEW, wx.ART_OTHER, wx.Size(16, 15))) toolbar.AddTool( wx.ID_ANY, wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, wx.Size(16, 15))) toolbar.AddTool( wx.ID_ANY, wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_OTHER, wx.Size(16, 15))) toolbar.AddTool( wx.ID_ANY, wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE_AS, wx.ART_OTHER, wx.Size(16, 15))) toolbar.AddSeparator() toolbar.AddDropdownTool( wx.ID_UNDO, wx.ArtProvider.GetBitmap(wx.ART_UNDO, wx.ART_OTHER, wx.Size(16, 15))) toolbar.AddDropdownTool( wx.ID_REDO, wx.ArtProvider.GetBitmap(wx.ART_REDO, wx.ART_OTHER, wx.Size(16, 15))) toolbar.AddSeparator() toolbar.AddTool( wx.ID_ANY, wx.ArtProvider.GetBitmap(wx.ART_REPORT_VIEW, wx.ART_OTHER, wx.Size(16, 15))) toolbar.AddTool( wx.ID_ANY, wx.ArtProvider.GetBitmap(wx.ART_LIST_VIEW, wx.ART_OTHER, wx.Size(16, 15))) toolbar.AddSeparator() toolbar.AddHybridTool( ID_POSITION_LEFT, CreateBitmap("position_left"), "Align ribbonbar vertically\non the left\nfor demonstration purposes" ) toolbar.AddHybridTool( ID_POSITION_TOP, CreateBitmap("position_top"), "Align the ribbonbar horizontally\nat the top\nfor demonstration purposes" ) toolbar.AddSeparator() toolbar.AddHybridTool( wx.ID_PRINT, wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_OTHER, wx.Size(16, 15)), "This is the Print button tooltip\ndemonstrating a tooltip") toolbar.SetRows(2, 3) selection_panel = RB.RibbonPanel(home, wx.ID_ANY, "Selection", CreateBitmap("selection_panel")) selection = RB.RibbonButtonBar(selection_panel) selection.AddSimpleButton( ID_SELECTION_EXPAND_V, "Expand Vertically", CreateBitmap("expand_selection_v"), "This is a tooltip for Expand Vertically\ndemonstrating a tooltip") selection.AddSimpleButton(ID_SELECTION_EXPAND_H, "Expand Horizontally", CreateBitmap("expand_selection_h"), "") selection.AddButton(ID_SELECTION_CONTRACT, "Contract", CreateBitmap("auto_crop_selection"), CreateBitmap("auto_crop_selection_small")) shapes_panel = RB.RibbonPanel(home, wx.ID_ANY, "Shapes", CreateBitmap("circle_small")) shapes = RB.RibbonButtonBar(shapes_panel) shapes.AddButton( ID_CIRCLE, "Circle", CreateBitmap("circle"), CreateBitmap("circle_small"), help_string= "This is a tooltip for the circle button\ndemonstrating another tooltip", kind=RB.RIBBON_BUTTON_TOGGLE) shapes.AddSimpleButton(ID_CROSS, "Cross", CreateBitmap("cross"), "") shapes.AddHybridButton(ID_TRIANGLE, "Triangle", CreateBitmap("triangle")) shapes.AddSimpleButton(ID_SQUARE, "Square", CreateBitmap("square"), "") shapes.AddDropdownButton(ID_POLYGON, "Other Polygon", CreateBitmap("hexagon"), "") sizer_panel = RB.RibbonPanel(home, wx.ID_ANY, "Panel with Sizer", wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, agwStyle=RB.RIBBON_PANEL_DEFAULT_STYLE) strs = ["Item 1 using a box sizer now", "Item 2 using a box sizer now"] sizer_panelcombo = wx.ComboBox(sizer_panel, wx.ID_ANY, "", wx.DefaultPosition, wx.DefaultSize, strs, wx.CB_READONLY) sizer_panelcombo2 = wx.ComboBox(sizer_panel, wx.ID_ANY, "", wx.DefaultPosition, wx.DefaultSize, strs, wx.CB_READONLY) sizer_panelcombo.Select(0) sizer_panelcombo2.Select(1) sizer_panelcombo.SetMinSize(wx.Size(150, -1)) sizer_panelcombo2.SetMinSize(wx.Size(150, -1)) # not using wx.WrapSizer(wx.HORIZONTAL) as it reports an incorrect min height sizer_panelsizer = wx.BoxSizer(wx.VERTICAL) sizer_panelsizer.AddStretchSpacer(1) sizer_panelsizer.Add(sizer_panelcombo, 0, wx.ALL | wx.EXPAND, 2) sizer_panelsizer.Add(sizer_panelcombo2, 0, wx.ALL | wx.EXPAND, 2) sizer_panelsizer.AddStretchSpacer(1) sizer_panel.SetSizer(sizer_panelsizer) label_font = wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_LIGHT) self._bitmap_creation_dc.SetFont(label_font) scheme = RB.RibbonPage(self._ribbon, wx.ID_ANY, "Appearance", CreateBitmap("eye")) self._default_primary, self._default_secondary, self._default_tertiary = self._ribbon.GetArtProvider( ).GetColourScheme(1, 1, 1) provider_panel = RB.RibbonPanel( scheme, wx.ID_ANY, "Art", wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, agwStyle=RB.RIBBON_PANEL_NO_AUTO_MINIMISE) provider_bar = RB.RibbonButtonBar(provider_panel, wx.ID_ANY) provider_bar.AddSimpleButton( ID_DEFAULT_PROVIDER, "Default Provider", wx.ArtProvider.GetBitmap(wx.ART_QUESTION, wx.ART_OTHER, wx.Size(32, 32)), "") provider_bar.AddSimpleButton(ID_AUI_PROVIDER, "AUI Provider", CreateBitmap("aui_style"), "") provider_bar.AddSimpleButton(ID_MSW_PROVIDER, "MSW Provider", CreateBitmap("msw_style"), "") primary_panel = RB.RibbonPanel(scheme, wx.ID_ANY, "Primary Colour", CreateBitmap("colours")) self._primary_gallery = self.PopulateColoursPanel( primary_panel, self._default_primary, ID_PRIMARY_COLOUR) secondary_panel = RB.RibbonPanel(scheme, wx.ID_ANY, "Secondary Colour", CreateBitmap("colours")) self._secondary_gallery = self.PopulateColoursPanel( secondary_panel, self._default_secondary, ID_SECONDARY_COLOUR) dummy_2 = RB.RibbonPage(self._ribbon, wx.ID_ANY, "Empty Page", CreateBitmap("empty")) dummy_3 = RB.RibbonPage(self._ribbon, wx.ID_ANY, "Another Page", CreateBitmap("empty")) self._ribbon.Realize() self._logwindow = wx.TextCtrl( panel, wx.ID_ANY, "", wx.DefaultPosition, wx.DefaultSize, wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_LEFT | wx.TE_BESTWRAP | wx.BORDER_NONE) self._togglePanels = wx.ToggleButton(panel, ID_TOGGLE_PANELS, "&Toggle panels") self._togglePanels.SetValue(True) s = wx.BoxSizer(wx.VERTICAL) s.Add(self._ribbon, 0, wx.EXPAND) s.Add(self._logwindow, 1, wx.EXPAND) s.Add(self._togglePanels, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 10) panel.SetSizer(s) self.panel = panel self.BindEvents([selection, shapes, provider_bar]) self.SetIcon(images.Mondrian.Icon) self.CenterOnScreen() self.Show()
def __init__(self, parent, id=wx.ID_ANY, title="", pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, log=None): wx.Frame.__init__(self, parent, id, title, pos, size, style) self._ribbon = RB.RibbonBar(self, wx.ID_ANY) self._bitmap_creation_dc = wx.MemoryDC() self._colour_data = wx.ColourData() home = RB.RibbonPage(self._ribbon, wx.ID_ANY, "Examples", CreateBitmap("ribbon")) toolbar_panel = RB.RibbonPanel(home, wx.ID_ANY, "Toolbar", wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, agwStyle=RB.RIBBON_PANEL_NO_AUTO_MINIMISE) toolbar = RB.RibbonToolBar(toolbar_panel, ID_MAIN_TOOLBAR) toolbar.AddTool(wx.ID_ANY, CreateBitmap("align_left")) toolbar.AddTool(wx.ID_ANY, CreateBitmap("align_center")) toolbar.AddTool(wx.ID_ANY, CreateBitmap("align_right")) toolbar.AddSeparator() toolbar.AddHybridTool(wx.ID_NEW, wx.ArtProvider.GetBitmap(wx.ART_NEW, wx.ART_OTHER, wx.Size(16, 15))) toolbar.AddTool(wx.ID_ANY, wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, wx.Size(16, 15))) toolbar.AddTool(wx.ID_ANY, wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_OTHER, wx.Size(16, 15))) toolbar.AddTool(wx.ID_ANY, wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE_AS, wx.ART_OTHER, wx.Size(16, 15))) toolbar.AddSeparator() toolbar.AddDropdownTool(wx.ID_UNDO, wx.ArtProvider.GetBitmap(wx.ART_UNDO, wx.ART_OTHER, wx.Size(16, 15))) toolbar.AddDropdownTool(wx.ID_REDO, wx.ArtProvider.GetBitmap(wx.ART_REDO, wx.ART_OTHER, wx.Size(16, 15))) toolbar.AddSeparator() toolbar.AddTool(wx.ID_ANY, wx.ArtProvider.GetBitmap(wx.ART_REPORT_VIEW, wx.ART_OTHER, wx.Size(16, 15))) toolbar.AddTool(wx.ID_ANY, wx.ArtProvider.GetBitmap(wx.ART_LIST_VIEW, wx.ART_OTHER, wx.Size(16, 15))) toolbar.AddSeparator() toolbar.AddHybridTool(ID_POSITION_LEFT, CreateBitmap("position_left")) toolbar.AddHybridTool(ID_POSITION_TOP, CreateBitmap("position_top")) toolbar.AddSeparator() toolbar.AddHybridTool(wx.ID_PRINT, wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_OTHER, wx.Size(16, 15))) toolbar.SetRows(2, 3) selection_panel = RB.RibbonPanel(home, wx.ID_ANY, "Selection", CreateBitmap("selection_panel")) selection = RB.RibbonButtonBar(selection_panel) selection.AddSimpleButton(ID_SELECTION_EXPAND_V, "Expand Vertically", CreateBitmap("expand_selection_v"), "") selection.AddSimpleButton(ID_SELECTION_EXPAND_H, "Expand Horizontally", CreateBitmap("expand_selection_h"), "") selection.AddSimpleButton(ID_SELECTION_CONTRACT, "Contract", CreateBitmap("auto_crop_selection"), CreateBitmap("auto_crop_selection_small")) shapes_panel = RB.RibbonPanel(home, wx.ID_ANY, "Shapes", CreateBitmap("circle_small")) shapes = RB.RibbonButtonBar(shapes_panel) shapes.AddSimpleButton(ID_CIRCLE, "Circle", CreateBitmap("circle"), CreateBitmap("circle_small")) shapes.AddSimpleButton(ID_CROSS, "Cross", CreateBitmap("cross"), "") shapes.AddHybridButton(ID_TRIANGLE, "Triangle", CreateBitmap("triangle")) shapes.AddSimpleButton(ID_SQUARE, "Square", CreateBitmap("square"), "") shapes.AddDropdownButton(ID_POLYGON, "Other Polygon", CreateBitmap("hexagon"), "") dummy_1 = RB.RibbonPanel(home, wx.ID_ANY, "Another Panel", wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, agwStyle=RB.RIBBON_PANEL_EXT_BUTTON) label_font = wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_LIGHT) self._bitmap_creation_dc.SetFont(label_font) scheme = RB.RibbonPage(self._ribbon, wx.ID_ANY, "Appearance", CreateBitmap("eye")) self._default_primary, self._default_secondary, self._default_tertiary = self._ribbon.GetArtProvider().GetColourScheme(1, 1, 1) provider_panel = RB.RibbonPanel(scheme, wx.ID_ANY, "Art", wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, agwStyle=RB.RIBBON_PANEL_NO_AUTO_MINIMISE) provider_bar = RB.RibbonButtonBar(provider_panel, wx.ID_ANY) provider_bar.AddSimpleButton(ID_DEFAULT_PROVIDER, "Default Provider", wx.ArtProvider.GetBitmap(wx.ART_QUESTION, wx.ART_OTHER, wx.Size(32, 32)), "") provider_bar.AddSimpleButton(ID_AUI_PROVIDER, "AUI Provider", CreateBitmap("aui_style"), "") provider_bar.AddSimpleButton(ID_MSW_PROVIDER, "MSW Provider", CreateBitmap("msw_style"), "") primary_panel = RB.RibbonPanel(scheme, wx.ID_ANY, "Primary Colour", CreateBitmap("colours")) self._primary_gallery = self.PopulateColoursPanel(primary_panel, self._default_primary, ID_PRIMARY_COLOUR) secondary_panel = RB.RibbonPanel(scheme, wx.ID_ANY, "Secondary Colour", CreateBitmap("colours")) self._secondary_gallery = self.PopulateColoursPanel(secondary_panel, self._default_secondary, ID_SECONDARY_COLOUR) dummy_2 = RB.RibbonPage(self._ribbon, wx.ID_ANY, "Empty Page", CreateBitmap("empty")) dummy_3 = RB.RibbonPage(self._ribbon, wx.ID_ANY, "Another Page", CreateBitmap("empty")) self._ribbon.Realize() self._logwindow = wx.TextCtrl(self, wx.ID_ANY, "", wx.DefaultPosition, wx.DefaultSize, wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_LEFT | wx.TE_BESTWRAP | wx.BORDER_NONE) s = wx.BoxSizer(wx.VERTICAL) s.Add(self._ribbon, 0, wx.EXPAND) s.Add(self._logwindow, 1, wx.EXPAND) self.SetSizer(s) self.BindEvents([selection, shapes, provider_bar]) self.SetIcon(images.Mondrian.Icon) self.CenterOnScreen() self.Show()