コード例 #1
0
    def ribbonBar(self):
        self.ID_TB_NEW = wx.NewId()
        self.ID_TB_DEL_MEM = wx.NewId()
        self.ID_TB_EDIT =wx.NewId()
        self.ID_TB_GENE_PIC = wx.NewId()
        self.ID_TB_SAVE_AS = wx.NewId()
        self.ID_TB_EXIT = wx.NewId()
        self.ID_TB_ABOUT = wx.NewId()
        self.ID_TB_BROWSE = wx.NewId()
        
        self._ribbon = RB.RibbonBar(self, wx.ID_ANY)

        home = RB.RibbonPage(self._ribbon, wx.ID_ANY, "File")
        
        toolbar_panel = RB.RibbonPanel(home, wx.ID_ANY, u"Tools", wx.NullBitmap, wx.DefaultPosition,agwStyle=RB.RIBBON_PANEL_NO_AUTO_MINIMISE)
        tool_bar = RB.RibbonButtonBar(toolbar_panel, -1)
        tool_bar.AddSimpleButton(self.ID_TB_NEW, u'Add', wx.BitmapFromImage((wx.Image(os.path.join(self.imagedir, 'add.png'),wx.BITMAP_TYPE_PNG)).Rescale(48,48)),"")
        tool_bar.AddSimpleButton(self.ID_TB_EDIT,u'Edit', wx.BitmapFromImage((wx.Image(os.path.join(self.imagedir, 'edit.png'),wx.BITMAP_TYPE_PNG)).Rescale(48,48)),"")
        tool_bar.AddSimpleButton(self.ID_TB_DEL_MEM,u'Del', wx.BitmapFromImage((wx.Image(os.path.join(self.imagedir, 'del.png'),wx.BITMAP_TYPE_PNG)).Rescale(48,48)),"")
        tool_bar.AddSimpleButton(self.ID_TB_GENE_PIC, u"Redraw",wx.BitmapFromImage((wx.Image(os.path.join(self.imagedir, 'gene.png'),wx.BITMAP_TYPE_PNG)).Rescale(48,48)),"")
        tool_bar.AddSimpleButton(self.ID_TB_SAVE_AS, u"Save",wx.BitmapFromImage((wx.Image(os.path.join(self.imagedir, 'save.png'),wx.BITMAP_TYPE_PNG)).Rescale(48,48)),"")
        
        other_panel = RB.RibbonPanel(home, wx.ID_ANY,u"Other", wx.NullBitmap, wx.DefaultPosition,agwStyle=RB.RIBBON_PANEL_NO_AUTO_MINIMISE)
        other_bar = RB.RibbonButtonBar(other_panel, -1)
        other_bar.AddSimpleButton(self.ID_TB_EXIT, u"Exit", wx.BitmapFromImage((wx.Image(os.path.join(self.imagedir, 'exit.png'),wx.BITMAP_TYPE_PNG)).Rescale(48,47)),"")
        
        RB.RibbonPanel(home, wx.ID_ANY,"", wx.NullBitmap, wx.DefaultPosition,agwStyle=RB.RIBBON_PANEL_NO_AUTO_MINIMISE)
        
        help = RB.RibbonPage(self._ribbon, wx.ID_ANY, "Help")
        
        about_panel = RB.RibbonPanel(help, wx.ID_ANY, "About", wx.NullBitmap, wx.DefaultPosition,agwStyle=RB.RIBBON_PANEL_NO_AUTO_MINIMISE)
        about_bar = RB.RibbonButtonBar(about_panel, -1)
        about_bar.AddSimpleButton(self.ID_TB_ABOUT,u"Help", wx.BitmapFromImage((wx.Image(os.path.join(self.imagedir, 'about.png'),wx.BITMAP_TYPE_PNG)).Rescale(48,48)),"")
        about_bar.AddSimpleButton(self.ID_TB_BROWSE, u"Browse",wx.BitmapFromImage((wx.Image(os.path.join(self.imagedir, 'browse.png'),wx.BITMAP_TYPE_PNG)).Rescale(48,48)),"")
        
        RB.RibbonPanel(help, wx.ID_ANY,"", wx.NullBitmap, wx.DefaultPosition,agwStyle=RB.RIBBON_PANEL_NO_AUTO_MINIMISE)
        
        self._ribbon.Realize()
        self.s.Add(self._ribbon, 0, wx.EXPAND)
      
        self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.OnAdd, id=self.ID_TB_NEW)
        self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.OnSaveAs, id=self.ID_TB_SAVE_AS)
        self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.OnEdit, id=self.ID_TB_EDIT)
        self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.OnDelMem, id=self.ID_TB_DEL_MEM)
        self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.OnRedraw, id=self.ID_TB_GENE_PIC)
        self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.OnClose, id=self.ID_TB_EXIT)
        self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.OnAboutDlg, id=self.ID_TB_ABOUT)
        self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.OnBrowse, id=self.ID_TB_BROWSE)
コード例 #2
0
ファイル: RibbonBar.py プロジェクト: rwal127/Qube
    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()
コード例 #3
0
    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()