def init_ui(self): if utils.isWin32(): self._tbIcon = trayicon.TrayIcon(self, images.logo48.Icon) self._root_panel = wx.Panel(self) self._panel = wx.Panel(self._root_panel) self._ribbon = RB.RibbonBar(self._root_panel, ID_RIBBON, style=RB.RIBBON_BAR_DEFAULT_STYLE | RB.RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS) rb_page = RB.RibbonPage(self._ribbon, ID_PAGE_IP, 'IP代理地址池') rb_panel = RB.RibbonPanel(rb_page, wx.ID_ANY, 'IP工具', style=RB.RIBBON_PANEL_NO_AUTO_MINIMISE | RB.RIBBON_PANEL_EXT_BUTTON) rb_bar = RB.RibbonButtonBar(rb_panel, wx.ID_ANY) rb_bar.AddToggleButton(ID_IP_POOL, 'IP代理爬取', images.pool.Bitmap) rb_bar.AddToggleButton(ID_IP_TEST, 'IP代理测试', images.test.Bitmap) rb_panel = RB.RibbonPanel(rb_page, wx.ID_ANY, '设置') rb_bar = RB.RibbonButtonBar(rb_panel, wx.ID_ANY) rb_bar.AddButton(ID_IP_SETTING, '设置', images.setting.Bitmap) rb_page = RB.RibbonPage(self._ribbon, ID_PAGE_ZH, '知乎') rb_panel = RB.RibbonPanel(rb_page, wx.ID_ANY, '知乎工具', style=RB.RIBBON_PANEL_NO_AUTO_MINIMISE | RB.RIBBON_PANEL_EXT_BUTTON) rb_bar = RB.RibbonButtonBar(rb_panel, wx.ID_ANY) rb_bar.AddToggleButton(ID_ZH_START, '知乎爬取', images.pool.Bitmap) self._ribbon.Realize() self.set_ribbon_page(ID_PAGE_IP) #-------------------------------------------------------------- self.proxyspider = ProxySpider(wx.GetApp().cfg_path) #-------------------------------------------------------------- s = wx.BoxSizer(wx.VERTICAL) s.Add(self._ribbon, 0, wx.EXPAND) s.Add(self._panel, 1, wx.EXPAND) #s.Add(self.poolpanel, 1, wx.EXPAND) self._root_panel.SetSizer(s) self.SetIcon(images.logo48.Icon) self.CenterOnScreen() self.set_art_provider(RB.RibbonMSWArtProvider())
def InitUI(self): fonts = [ "Arial", "Courier New", "Consolas", "Clarendon", "Comic Sans Ms", "MS Sans Serif", "MS Serif", "Times New Roman", "Serif", "Symbol", "System", "Verdana" ] font_sizes = ['10', '11', '12', '13', '14', '15', '16', '17', '18'] # creating menubar menubar = wx.MenuBar() filemenu = wx.Menu() menubar.Append(filemenu, 'File') newi = wx.MenuItem(filemenu, 1, 'New\tCtrl+N', 'New File') newi.SetBitmap(wx.Bitmap('menuicons/new.png')) filemenu.Append(newi) openi = wx.MenuItem(filemenu, 2, 'Open\tCtrl+O', 'Open File') openi.SetBitmap(wx.Bitmap('menuicons/open.png')) filemenu.Append(openi) filemenu.AppendSeparator() savei = wx.MenuItem(filemenu, 3, 'Save\tCtrl+S', 'Save File') savei.SetBitmap(wx.Bitmap('menuicons/save.png')) filemenu.Append(savei) save_asi = wx.MenuItem(filemenu, 4, 'Save As\tCtrl+Shift+S', 'Save As') save_asi.SetBitmap(wx.Bitmap('menuicons/save-as.png')) filemenu.Append(save_asi) filemenu.AppendSeparator() exiti = wx.MenuItem(filemenu, 5, 'Exit\tAlt+F4', 'Exit') exiti.SetBitmap(wx.Bitmap('menuicons/exit.png')) filemenu.Append(exiti) editmenu = wx.Menu() menubar.Append(editmenu, 'Edit') undoi = wx.MenuItem(editmenu, 6, 'Undo\tCtrl+Z', 'Undo') undoi.SetBitmap(wx.Bitmap('menuicons/undo.png')) editmenu.Append(undoi) redoi = wx.MenuItem(editmenu, 7, 'Redo\tCtrl+Y', 'Redo') redoi.SetBitmap(wx.Bitmap('menuicons/redo.png')) editmenu.Append(redoi) editmenu.AppendSeparator() cuti = wx.MenuItem(editmenu, 8, 'Cut\tCtrl+X', 'Cut') cuti.SetBitmap(wx.Bitmap('menuicons/cut.png')) editmenu.Append(cuti) copyi = wx.MenuItem(editmenu, 9, 'Copy\tCtrl+C', 'Copy') copyi.SetBitmap(wx.Bitmap('menuicons/copy.png')) editmenu.Append(copyi) pastei = wx.MenuItem(editmenu, 10, 'Paste\tCtrl+V', 'Paste') pastei.SetBitmap(wx.Bitmap('menuicons/paste.png')) editmenu.Append(pastei) editmenu.AppendSeparator() select_alli = wx.MenuItem(editmenu, 11, 'Select All\tCtrl+A', 'Select All') select_alli.SetBitmap(wx.Bitmap('menuicons/select-all.png')) editmenu.Append(select_alli) deletei = wx.MenuItem(editmenu, 12, 'Delete\tCtrl+D', 'Delete') deletei.SetBitmap(wx.Bitmap('menuicons/delete.png')) editmenu.Append(deletei) go_to_linei = editmenu.Append(wx.ID_ANY, "Go To Line\tCtrl+G", 'Go To Line') editmenu.AppendSeparator() findi = wx.MenuItem(editmenu, 13, 'Find\tCtrl+F', 'Find') findi.SetBitmap(wx.Bitmap('menuicons/find.png')) editmenu.Append(findi) replacei = wx.MenuItem(editmenu, 14, 'Replace\tCtrl+H', 'Replace') replacei.SetBitmap(wx.Bitmap('menuicons/replace.png')) editmenu.Append(replacei) datei = editmenu.Append(wx.ID_ANY, "Date/Time\tF5", "Date/Time") viewmenu = wx.Menu() menubar.Append(viewmenu, 'View') self.linenumberi = viewmenu.Append(wx.ID_ANY, 'Show/Hide Line Number', 'Show/Hide Line Number', wx.ITEM_CHECK) self.statusbari = viewmenu.Append(wx.ID_ANY, 'Show/Hide Status Bar', 'Show/Hide Status Bar', wx.ITEM_CHECK) viewmenu.Check(self.linenumberi.GetId(), True) viewmenu.Check(self.statusbari.GetId(), True) fontmenu = wx.Menu() menubar.Append(fontmenu, 'Font') boldi = wx.MenuItem(fontmenu, 15, 'Bold\tCtrl+B', 'Bold') boldi.SetBitmap(wx.Bitmap('menuicons/bold.png')) fontmenu.Append(boldi) italici = wx.MenuItem(fontmenu, 16, 'Italic\tCtrl+I', 'Italic') italici.SetBitmap(wx.Bitmap('menuicons/italic.png')) fontmenu.Append(italici) underlinei = wx.MenuItem(fontmenu, 17, 'Underline\tCtrl+U', 'Underline') underlinei.SetBitmap(wx.Bitmap('menuicons/underline.png')) fontmenu.Append(underlinei) fontmenu.AppendSeparator() uppercasei = wx.MenuItem(fontmenu, 18, 'Upper Case', 'Upper Case') uppercasei.SetBitmap(wx.Bitmap('menuicons/uppercase.png')) fontmenu.Append(uppercasei) lowercasei = wx.MenuItem(fontmenu, 19, 'Lower Case', 'Lower Case') lowercasei.SetBitmap(wx.Bitmap('menuicons/lowercase.png')) fontmenu.Append(lowercasei) fontsi = wx.Menu() ariali = fontsi.Append(wx.ID_ANY, 'Arial') courier_newi = fontsi.Append(wx.ID_ANY, 'Courier New') consolasi = fontsi.Append(wx.ID_ANY, 'Consolas') clarendoni = fontsi.Append(wx.ID_ANY, 'Clarendon') comic_sansi = fontsi.Append(wx.ID_ANY, 'Comic Sans Ms') ms_sansi = fontsi.Append(wx.ID_ANY, 'MS Sans Serif') ms_serifi = fontsi.Append(wx.ID_ANY, 'MS Serif') timesi = fontsi.Append(wx.ID_ANY, 'Times New Roman') serifi = fontsi.Append(wx.ID_ANY, 'Serif') symboli = fontsi.Append(wx.ID_ANY, 'Symbol') systemi = fontsi.Append(wx.ID_ANY, 'System') verdanai = fontsi.Append(wx.ID_ANY, 'Verdana') fontmenu.Append(wx.ID_ANY, 'Fonts', fontsi) aboutmenu = wx.Menu() menubar.Append(aboutmenu, 'About') abouti = aboutmenu.Append(wx.ID_ANY, 'About WxEditor') self.SetMenuBar(menubar) # current directory and file name self.dirname = '' self.filename = '' # set Default pos and size self.pos = 0 self.size = 0 # show and hide line number self.linenumberEnable = True # Set True value for bold, italic, underline self.EnableBold = True self.EnableItalic = True self.EnableUnderline = True # bind menu icons and functions self.Bind(wx.EVT_MENU, self.new, newi) self.Bind(wx.EVT_MENU, self.open_file, openi) self.Bind(wx.EVT_MENU, self.save, savei) self.Bind(wx.EVT_MENU, self.save_as, save_asi) self.Bind(wx.EVT_MENU, self.exit, exiti) self.Bind(wx.EVT_MENU, self.undo, undoi) self.Bind(wx.EVT_MENU, self.redo, redoi) self.Bind(wx.EVT_MENU, self.cut, cuti) self.Bind(wx.EVT_MENU, self.copy, copyi) self.Bind(wx.EVT_MENU, self.paste, pastei) self.Bind(wx.EVT_MENU, self.select_all, select_alli) self.Bind(wx.EVT_MENU, self.delete, deletei) self.Bind(wx.EVT_MENU, self.go_to_line, go_to_linei) self.Bind(wx.EVT_MENU, self.find_button, findi) self.Bind(wx.EVT_MENU, self.replace_button, replacei) self.Bind(wx.EVT_MENU, self.date_time, datei) self.Bind(wx.EVT_FIND, self.find) self.Bind(wx.EVT_FIND_REPLACE, self.replace) self.Bind(wx.EVT_FIND_REPLACE_ALL, self.replace_all) self.Bind(wx.EVT_MENU, self.show_hide_linenumber, self.linenumberi) self.Bind(wx.EVT_MENU, self.show_hide_statusbar, self.statusbari) self.Bind(wx.EVT_MENU, self.bold, boldi) self.Bind(wx.EVT_MENU, self.italic, italici) self.Bind(wx.EVT_MENU, self.underline, underlinei) self.Bind(wx.EVT_MENU, self.uppercase, uppercasei) self.Bind(wx.EVT_MENU, self.lowercase, lowercasei) self.Bind(wx.EVT_MENU, self.arial, ariali) self.Bind(wx.EVT_MENU, self.courier_new, courier_newi) self.Bind(wx.EVT_MENU, self.consolas, consolasi) self.Bind(wx.EVT_MENU, self.clarendon, clarendoni) self.Bind(wx.EVT_MENU, self.comic_sans, comic_sansi) self.Bind(wx.EVT_MENU, self.ms_sans, ms_sansi) self.Bind(wx.EVT_MENU, self.ms_serif, ms_serifi) self.Bind(wx.EVT_MENU, self.times, timesi) self.Bind(wx.EVT_MENU, self.serif, serifi) self.Bind(wx.EVT_MENU, self.symbol, symboli) self.Bind(wx.EVT_MENU, self.system, systemi) self.Bind(wx.EVT_MENU, self.verdana, verdanai) self.Bind(wx.EVT_MENU, self.about, abouti) # creating ribbon toolbar self.ribbon = RB.RibbonBar(self, wx.ID_ANY) home = RB.RibbonPage(self.ribbon, wx.ID_ANY, "", wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN)) file_panel = RB.RibbonPanel(home, wx.ID_ANY, "File", wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, RB.RIBBON_PANEL_DEFAULT_STYLE) ToolBar = RB.RibbonButtonBar(file_panel, wx.ID_ANY) ToolBar.AddButton(wx.ID_NEW, 'New', wx.Bitmap('toolicons/new.png')) ToolBar.AddButton(wx.ID_OPEN, 'Open', wx.Bitmap('toolicons/open.png')) ToolBar.AddButton(wx.ID_SAVE, 'Save', wx.Bitmap('toolicons/save.png')) ToolBar.AddButton(wx.ID_SAVEAS, 'Save As', wx.Bitmap('toolicons/save-as.png')) ToolBar.AddButton(wx.ID_EXIT, 'Exit', wx.Bitmap('toolicons/exit.png')) sizer_panel = RB.RibbonPanel(home, wx.ID_ANY, "Font Sizer") self.comboBox_1 = wx.ComboBox(sizer_panel, wx.ID_ANY, "", wx.DefaultPosition, wx.DefaultSize, fonts, wx.CB_READONLY) self.comboBox_2 = wx.ComboBox(sizer_panel, wx.ID_ANY, "", wx.DefaultPosition, wx.DefaultSize, font_sizes, wx.CB_READONLY) self.comboBox_1.Select(2) self.comboBox_2.Select(2) self.comboBox_1.SetMinSize(wx.Size(150, -1)) self.comboBox_2.SetMinSize(wx.Size(150, -1)) combobox = wx.BoxSizer(wx.VERTICAL) combobox.Add(self.comboBox_1, 0, wx.ALL | wx.EXPAND, 3) combobox.Add(self.comboBox_2, 0, wx.ALL | wx.EXPAND, 3) sizer_panel.SetSizer(combobox) edit_panel = RB.RibbonPanel(home, wx.ID_ANY, "Edit", wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, RB.RIBBON_PANEL_DEFAULT_STYLE) ToolBar = RB.RibbonButtonBar(edit_panel, wx.ID_ANY) ToolBar.AddButton(wx.ID_UNDO, 'Undo', wx.Bitmap('toolicons/undo.png')) ToolBar.AddButton(wx.ID_REDO, 'Redo', wx.Bitmap('toolicons/redo.png')) ToolBar.AddButton(wx.ID_CUT, 'Cut', wx.Bitmap('toolicons/cut.png')) ToolBar.AddButton(wx.ID_COPY, 'Copy', wx.Bitmap('toolicons/copy.png')) ToolBar.AddButton(wx.ID_PASTE, 'Paste', wx.Bitmap('toolicons/paste.png')) ToolBar.AddButton(wx.ID_SELECTALL, 'Select All', wx.Bitmap('toolicons/select-all.png')) ToolBar.AddButton(wx.ID_DELETE, 'Delete', wx.Bitmap('toolicons/delete.png')) ToolBar.AddButton(wx.ID_FIND, 'Find', wx.Bitmap('toolicons/find.png')) ToolBar.AddButton(wx.ID_REPLACE, 'Replace', wx.Bitmap('toolicons/replace.png')) font_panel = RB.RibbonPanel(home, wx.ID_ANY, "Font", wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, RB.RIBBON_PANEL_DEFAULT_STYLE) ToolBar = RB.RibbonButtonBar(font_panel, wx.ID_ANY) ToolBar.AddButton(wx.ID_BOLD, 'Bold', wx.Bitmap('toolicons/bold.png')) ToolBar.AddButton(wx.ID_ITALIC, 'Italic', wx.Bitmap('toolicons/italic.png')) ToolBar.AddButton(wx.ID_UNDERLINE, 'Underline', wx.Bitmap('toolicons/underline.png')) ToolBar.AddButton(wx.ID_UP, 'Uppercase', wx.Bitmap('toolicons/uppercase.png')) ToolBar.AddButton(wx.ID_LOWEST, 'Lowercase', wx.Bitmap('toolicons/lowercase.png')) self.ribbon.Realize() # bind ribbon toolbar icons and functions self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.new, id=wx.ID_NEW) self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.open_file, id=wx.ID_OPEN) self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.save, id=wx.ID_SAVE) self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.save_as, id=wx.ID_SAVEAS) self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.exit, id=wx.ID_EXIT) self.comboBox_1.Bind(wx.EVT_COMBOBOX, self.combo_font) self.comboBox_2.Bind(wx.EVT_COMBOBOX, self.combo_fontsize) self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.undo, id=wx.ID_UNDO) self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.redo, id=wx.ID_REDO) self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.cut, id=wx.ID_CUT) self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.copy, id=wx.ID_COPY) self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.paste, id=wx.ID_PASTE) self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.select_all, id=wx.ID_SELECTALL) self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.delete, id=wx.ID_DELETE) self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.find_button, id=wx.ID_FIND) self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.replace_button, id=wx.ID_REPLACE) self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.bold, id=wx.ID_BOLD) self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.italic, id=wx.ID_ITALIC) self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.underline, id=wx.ID_UNDERLINE) self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.uppercase, id=wx.ID_UP) self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.lowercase, id=wx.ID_LOWEST) # creating textarea self.Text = stc.StyledTextCtrl(self, style=wx.TE_MULTILINE | wx.TE_WORDWRAP) # Hide horizontal scrollbar self.Text.SetUseHorizontalScrollBar(show=0) # set default font & font size font = wx.Font(12, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, 'Consolas') self.Text.StyleSetFont(0, font) # creating line number self.Text.SetMarginType(1, stc.STC_MARGIN_NUMBER) # set margin 10 pixels between line number and text self.Text.SetMargins(10, 0) # set margin width self.leftMarginWidth = 35 self.Text.SetMarginWidth(1, self.leftMarginWidth) # creating status bar self.CreateStatusBar() self.StatusBar.SetBackgroundColour((220, 220, 220)) self.SetTitle("Untitled - WxEditor") self.Maximize(True) self.SetSize(900, 700) self.Center() # attach ribbon panel with ribbon page ribbonBox = wx.BoxSizer(wx.VERTICAL) ribbonBox.Add(self.ribbon, 0, wx.EXPAND) ribbonBox.Add(self.Text, 1, wx.EXPAND) self.SetSizer(ribbonBox) # show line and column number self.Text.Bind(wx.EVT_KEY_UP, self.status) self.status(self) # set the icon self.SetIcons( wx.IconBundle('icons/text-editor.png', wx.BITMAP_TYPE_ANY))
def __init__(self, parent): RB.RibbonBar.__init__(self, parent, style = RB.RIBBON_BAR_FLOW_HORIZONTAL | RB.RIBBON_BAR_SHOW_PAGE_LABELS | RB.RIBBON_BAR_SHOW_PAGE_ICONS | RB.RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS | RB.RIBBON_BAR_SHOW_HELP_BUTTON) self.ID_RECENT_FIRST = wx.ID_HIGHEST + 1 Ribbon.next_id = self.ID_RECENT_FIRST + wx.GetApp().MAX_RECENT_FILES self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) self.main_page = RB.RibbonPage(self, wx.ID_ANY, 'File', self.Image('file')) self.main_page.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) app = wx.GetApp() panel = RB.RibbonPanel(self.main_page, wx.ID_ANY, 'File', self.Image('new')) toolbar = RB.RibbonButtonBar(panel) Ribbon.AddToolBarTool(toolbar, 'New', 'new', 'New File', app.OnNew) Ribbon.AddToolBarTool(toolbar, "Open", 'open', "Open file", app.OnOpen, None, self.OnOpenDropdown) Ribbon.AddToolBarTool(toolbar, "Import", 'import', "Import file", app.OnImport) Ribbon.AddToolBarTool(toolbar, "Export", 'export', "Export file", app.OnExport) Ribbon.AddToolBarTool(toolbar, "Save", 'save', "Save file", app.OnSave, app.OnUpdateSave) Ribbon.AddToolBarTool(toolbar, "Save As", 'saveas', "Save file with given name", app.OnSaveAs) Ribbon.AddToolBarTool(toolbar, "Restore Defaults", 'restore', "Restore all defaults", app.OnResetDefaults) Ribbon.AddToolBarTool(toolbar, "About", 'about', "Software Information", app.OnAbout) panel = RB.RibbonPanel(self.main_page, wx.ID_ANY, 'Print', self.Image('print')) toolbar = RB.RibbonButtonBar(panel) Ribbon.AddToolBarTool(toolbar, "Print", 'print', "Print the view to a printer", app.OnPrint) Ribbon.AddToolBarTool(toolbar, "Page Setup", 'psetup', "Setup the printer layout", app.OnPageSetup) Ribbon.AddToolBarTool(toolbar, "Print Preview", 'ppreview', "Show a preview of the print view", app.OnPrintPreview) panel = RB.RibbonPanel(self.main_page, wx.ID_ANY, 'Edit', self.Image('cut')) toolbar = RB.RibbonButtonBar(panel) Ribbon.AddToolBarTool(toolbar, "Undo", 'undo', 'Undo the previous command', app.OnUndo, app.OnUpdateUndo, None) Ribbon.AddToolBarTool(toolbar, "Redo", 'redo', 'Redo the next command', app.OnRedo, app.OnUpdateRedo, None) Ribbon.AddToolBarTool(toolbar, "Cut", 'cut', 'Cut selected items to the clipboard', app.OnCut, app.OnUpdateCut) Ribbon.AddToolBarTool(toolbar, "Copy", 'copy', 'Copy selected items to the clipboard', app.OnCopy, app.OnUpdateCopy) Ribbon.AddToolBarTool(toolbar, "Paste", 'paste', 'Paste items from the clipboard', app.OnPaste, app.OnUpdatePaste) Ribbon.AddToolBarTool(toolbar, "Delete", 'delete', 'Delete selected items', app.OnDelete, app.OnUpdateDelete) Ribbon.AddToolBarTool(toolbar, "Select", 'select', 'Select Mode', app.OnSelectMode) Ribbon.AddToolBarTool(toolbar, "Filter", 'filter', 'Edit theSelection Filter', app.OnFilter) self.main_page.Realize() self.geom_page = RB.RibbonPage(self, wx.ID_ANY, 'Geom', self.Image('geom')) self.geom_page.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) panel = RB.RibbonPanel(self.geom_page, wx.ID_ANY, 'Sketches', self.Image('lines')) toolbar = RB.RibbonButtonBar(panel) Ribbon.AddToolBarTool(toolbar,'Lines', 'lines', 'Draw a sketch with lines and arcs', app.OnLines) Ribbon.AddToolBarTool(toolbar,'Rectangles', 'rect', 'Draw rectangles', app.OnRectangles) Ribbon.AddToolBarTool(toolbar,'Obrounds', 'obround', 'Draw obrounds', app.OnObrounds) Ribbon.AddToolBarTool(toolbar,'Polygons', 'pentagon', 'Draw polygons', app.OnPolygons) Ribbon.AddToolBarTool(toolbar,'Gear', 'gear', 'Add a gear', app.OnGear) CurrentColorButton('Drawing Color', 'Edit current drawing color').AddToToolbar(toolbar) panel = RB.RibbonPanel(self.geom_page, wx.ID_ANY, 'Circles', self.Image('circ3p')) toolbar = RB.RibbonButtonBar(panel) Ribbon.AddToolBarTool(toolbar,'3 Points', 'circ3p', 'Draw circles through 3 points', app.OnCircles3p) Ribbon.AddToolBarTool(toolbar,'2 Points', 'circ2p', 'Draw circles, centre and point', app.OnCircles2p) Ribbon.AddToolBarTool(toolbar,'Radius', 'circpr', 'Draw circles, centre and radius', app.OnCircles1p) panel = RB.RibbonPanel(self.geom_page, wx.ID_ANY, 'OtherDrawing', self.Image('point')) self.other_drawing_toolbar = RB.RibbonButtonBar(panel) Ribbon.AddToolBarTool(self.other_drawing_toolbar,'Infinite Line', 'iline', 'Drawing Infinite Lines', app.OnILine) Ribbon.AddToolBarTool(self.other_drawing_toolbar,'Points', 'point', 'Drawing Points', app.OnPoints) panel = RB.RibbonPanel(self.geom_page, wx.ID_ANY, 'Text', self.Image('text')) toolbar = RB.RibbonButtonBar(panel) Ribbon.AddToolBarTool(toolbar,'Text', 'text', 'Add a text object', app.OnText) Ribbon.AddToolBarTool(toolbar,'Dimensioning', 'dimension', 'Add a dimension', app.OnDimensioning) panel = RB.RibbonPanel(self.geom_page, wx.ID_ANY, 'Snapping', self.Image('endof')) toolbar = RB.RibbonButtonBar(panel) OnOffButton('Endof', 'endof', 'endofgray', cad.GetDigitizeEnd, cad.SetDigitizeEnd, 'Snap to end point').AddToToolbar(toolbar) OnOffButton('Inters', 'inters', 'intersgray', cad.GetDigitizeInters, cad.SetDigitizeInters, 'Snap to intersection').AddToToolbar(toolbar) OnOffButton('Centre', 'centre', 'centregray', cad.GetDigitizeCentre, cad.SetDigitizeCentre, 'Snap to centre').AddToToolbar(toolbar) OnOffButton('Midpoint', 'midpoint', 'midpointgray', cad.GetDigitizeMidpoint, cad.SetDigitizeMidpoint, 'Snap to midpoint').AddToToolbar(toolbar) OnOffButton('Grid', 'snap', 'snapgray', cad.GetDigitizeSnapToGrid, cad.SetDigitizeSnapToGrid, 'Snap to grid', self.OnSnapDropdown).AddToToolbar(toolbar) self.geom_page.Realize() move_page = RB.RibbonPage(self, wx.ID_ANY, 'Move', self.Image('coordsys')) move_page.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) panel = RB.RibbonPanel(move_page, wx.ID_ANY, 'Set Origin', self.Image('coordsys')) toolbar = RB.RibbonButtonBar(panel) Ribbon.AddToolBarTool(toolbar,'3 Points', 'coordsys', 'Pick 3 points', app.OnSetOrigin3Points) Ribbon.AddToolBarTool(toolbar,'1 point', 'coordsys', 'Pick 1 point', app.OnSetOrigin1Point) panel = RB.RibbonPanel(move_page, wx.ID_ANY, 'Transformations', self.Image('movet')) toolbar = RB.RibbonButtonBar(panel) Ribbon.AddToolBarTool(toolbar,'Move Translate', 'movet', 'Translate selected items', app.OnMoveTranslate) Ribbon.AddToolBarTool(toolbar,'Copy Translate', 'copyt', 'Copy and translate selected items', app.OnCopyTranslate) Ribbon.AddToolBarTool(toolbar,'Move Rotate', 'mover', 'Rotate selected items', app.OnMoveRotate) Ribbon.AddToolBarTool(toolbar,'Copy Rotate', 'copyr', 'Copy and rotate selected items', app.OnCopyRotate) Ribbon.AddToolBarTool(toolbar,'Mirror', 'copym', 'Mirror selected items', app.OnMirror) Ribbon.AddToolBarTool(toolbar,'Scale', 'moves', 'Scale selected items', app.OnMoveScale) Ribbon.AddToolBarTool(toolbar,'Move Origin', 'coords3', 'Move selected items from one origin to another', app.OnOriginTransform) move_page.Realize() view_page = RB.RibbonPage(self, wx.ID_ANY, 'View', self.Image('view')) view_page.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) panel = RB.RibbonPanel(view_page, wx.ID_ANY, 'Magnify', self.Image('mag')) toolbar = RB.RibbonButtonBar(panel) Ribbon.AddToolBarTool(toolbar,'Mag Extents', 'magextents', 'Zoom in to fit the extents of the drawing into the graphics window', app.OnMagExtents) Ribbon.AddToolBarTool(toolbar,'Mag No Rotation', 'magnorot', 'Zoom in to fit the extents of the drawing into the graphics window, but without rotating the view', app.OnMagNoRot) Ribbon.AddToolBarTool(toolbar,'Zoom Window', 'mag', 'Zoom in to a dragged window', app.OnMag) panel = RB.RibbonPanel(view_page, wx.ID_ANY, 'General', self.Image('fullscreen')) toolbar = RB.RibbonButtonBar(panel) Ribbon.AddToolBarTool(toolbar,'View Back', 'magprev', 'Go back to previous view', app.OnMagPrevious) Ribbon.AddToolBarTool(toolbar,'FullScreen', 'fullscreen', 'Switch to full screen view ( press escape to return )', app.OnFullScreen) Ribbon.AddToolBarTool(toolbar,'Redraw', 'redraw', 'Redraw', app.OnRedraw) panel = RB.RibbonPanel(view_page, wx.ID_ANY, 'Specific Views', self.Image('magxy')) toolbar = RB.RibbonButtonBar(panel) Ribbon.AddToolBarTool(toolbar,'View XY Front', 'magxy', 'View XY Front', app.OnMagXY) Ribbon.AddToolBarTool(toolbar,'View XY Back', 'magxym', 'View XY Back', app.OnMagXYM) Ribbon.AddToolBarTool(toolbar,'View XZ Top', 'magxz', 'View XZ Top', app.OnMagXZ) Ribbon.AddToolBarTool(toolbar,'View XZ Bottom', 'magxzm', 'View XZ Bottom', app.OnMagXZM) Ribbon.AddToolBarTool(toolbar,'View YZ Right', 'magyz', 'View YZ Right', app.OnMagYZ) Ribbon.AddToolBarTool(toolbar,'View YZ Left', 'magyzm', 'View YZ Left', app.OnMagYZM) Ribbon.AddToolBarTool(toolbar,'View XY Isometric', 'magxyz', 'View XY Isometric', app.OnMagXYZ) panel = RB.RibbonPanel(view_page, wx.ID_ANY, 'View Dragging', self.Image('viewrot')) toolbar = RB.RibbonButtonBar(panel) Ribbon.AddToolBarTool(toolbar,'View Rotate', 'viewrot', 'Enter view rotating mode', app.OnViewRotate) Ribbon.AddToolBarTool(toolbar,'View Zoom', 'zoom', 'Drag to zoom in and out', app.OnViewZoom) Ribbon.AddToolBarTool(toolbar,'View Pan', 'pan', 'Drag to move view', app.OnViewPan) panel = RB.RibbonPanel(view_page, wx.ID_ANY, 'Windows', self.Image('viewrot')) toolbar = RB.RibbonButtonBar(panel) for w in wx.GetApp().hideable_windows: WindowOnOffButton(self.GetParent().aui_manager.GetPane(w).name, wx.GetApp().hideable_windows[w]).AddToToolbar(toolbar) view_page.Realize() # Add extra pages before the Options page wx.GetApp().AddExtraRibbonPages(self) self.options_page = RB.RibbonPage(self, wx.ID_ANY, 'Options', self.Image('settings')) self.options_page.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) wx.GetApp().AddOptionsRibbonPanels(self) self.Realize()
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, style=RB.RIBBON_BAR_DEFAULT_STYLE |RB.RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS) 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", style=RB.RIBBON_PANEL_NO_AUTO_MINIMISE |RB.RIBBON_PANEL_EXT_BUTTON) 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.AddButton(ID_SELECTION_EXPAND_V, "Expand Vertically", CreateBitmap("expand_selection_v"), "This is a tooltip for Expand Vertically\ndemonstrating a tooltip") selection.AddButton(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.AddButton(ID_CROSS, "Cross", CreateBitmap("cross"), "") shapes.AddHybridButton(ID_TRIANGLE, "Triangle", CreateBitmap("triangle")) shapes.AddButton(ID_SQUARE, "Square", CreateBitmap("square"), "") shapes.AddDropdownButton(ID_POLYGON, "Other Polygon", CreateBitmap("hexagon"), "") sizer_panel = RB.RibbonPanel(home, wx.ID_ANY, "Panel with Sizer", style=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() provider_panel = RB.RibbonPanel(scheme, wx.ID_ANY, "Art", style=RB.RIBBON_PANEL_NO_AUTO_MINIMISE) provider_bar = RB.RibbonButtonBar(provider_panel, wx.ID_ANY) provider_bar.AddButton(ID_DEFAULT_PROVIDER, "Default Provider", wx.ArtProvider.GetBitmap(wx.ART_QUESTION, wx.ART_OTHER, wx.Size(32, 32)), "") provider_bar.AddButton(ID_AUI_PROVIDER, "AUI Provider", CreateBitmap("aui_style"), "") provider_bar.AddButton(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, toolbar_panel) self.SetIcon(images.Mondrian.Icon) self.CenterOnScreen()
def __init__(self, parent, id=wx.ID_ANY, title='', pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE): wx.Frame.__init__(self, parent, id, title, pos, size, style) if utils.isWin32(): self._tbIcon = trayicon.TrayIcon(self, images.logo24.Icon) self._panel = wx.Panel(self) self._ribbon = RB.RibbonBar(self._panel, style=RB.RIBBON_BAR_DEFAULT_STYLE | RB.RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS) rb_page = RB.RibbonPage(self._ribbon, wx.ID_ANY, 'Examples', images.logo.Bitmap) rb_panel = RB.RibbonPanel(rb_page, wx.ID_ANY, 'Toolbar', style=RB.RIBBON_PANEL_NO_AUTO_MINIMISE | RB.RIBBON_PANEL_EXT_BUTTON) rb_bar = RB.RibbonToolBar(rb_panel, wx.ID_ANY) rb_bar.AddTool(ID_BAR_FOO, wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, wx.Size(16, 16)), help_string='This is simple toolbar') rb_bar.AddToggleTool(ID_BAR_TOGGLE, images.logo16.Bitmap, "help string") rb_bar.AddHybridTool( wx.ID_NEW, wx.ArtProvider.GetBitmap(wx.ART_NEW, wx.ART_OTHER, wx.Size(16, 16)), 'This is the AddHybridTool button tooltip\ndemonstrating a tooltip' ) rb_bar.AddDropdownTool( wx.ID_ANY, wx.ArtProvider.GetBitmap(wx.ART_ADD_BOOKMARK, wx.ART_OTHER, wx.Size(16, 16))) rb_bar.AddSeparator() rb_bar.AddTool(wx.ID_ANY, images.logo16.Bitmap, kind=RB.RIBBON_BUTTON_TOGGLE) rb_bar.AddTool(wx.ID_ANY, images.logo16.Bitmap, kind=RB.RIBBON_BUTTON_HYBRID) rb_bar.AddTool(wx.ID_ANY, images.logo16.Bitmap, kind=RB.RIBBON_BUTTON_DROPDOWN) rb_panel2 = RB.RibbonPanel(rb_page, wx.ID_ANY, 'Buttons') rb_bar2 = RB.RibbonButtonBar(rb_panel2, wx.ID_ANY) # also has AddToggleTool AddHybridTool and AddDropdownTool rb_bar2.AddButton(wx.ID_ANY, "NormalButton", images.logo48.Bitmap) rb_bar2.AddButton(ID_BAR_TOGGLE2, "ToggleButton", images.logo48.Bitmap, kind=RB.RIBBON_BUTTON_TOGGLE) rb_bar2.AddButton(wx.ID_ANY, "HybridButton", images.logo48.Bitmap, kind=RB.RIBBON_BUTTON_HYBRID) rb_bar2.AddButton(wx.ID_ANY, "DropButton", images.logo48.Bitmap, kind=RB.RIBBON_BUTTON_DROPDOWN) rb_bar2.AddDropdownButton(ID_BTN_DROP, "Other Polygon", images.logo16.Bitmap, "") # min rows and max rows rb_bar.SetRows(2, 3) other = RB.RibbonPage(self._ribbon, wx.ID_ANY, 'Other', images.logo.Bitmap) self._ribbon.Realize() s = wx.BoxSizer(wx.VERTICAL) s.Add(self._ribbon, 0, wx.EXPAND) self._panel.SetSizer(s) self.BindEvents([rb_panel, rb_panel2]) #self.SetIcon(images.logo.Icon) self.CenterOnScreen() self.setArtProvider(RB.RibbonMSWArtProvider())
def __init__(self, *args, **kwds): # begin wxGlade: MeerK40t.__init__ kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self.SetSize((1200, 600)) self.DragAcceptFiles(True) self.project = project self.scene = LaserSceneView(self, wx.ID_ANY) self.scene.set_project(self.project) self.tree = CutConfiguration(self, ID_CUT_CONFIGURATION) panel = wx.Panel(self) self._ribbon = RB.RibbonBar(panel, style=RB.RIBBON_BAR_DEFAULT_STYLE | RB.RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS) self._bitmap_creation_dc = wx.MemoryDC() self._colour_data = wx.ColourData() home = RB.RibbonPage(self._ribbon, wx.ID_ANY, "Examples", icons8_opened_folder_50.GetBitmap()) toolbar_panel = RB.RibbonPanel(home, wx.ID_ANY, "Toolbar", style=RB.RIBBON_PANEL_NO_AUTO_MINIMISE | RB.RIBBON_PANEL_EXT_BUTTON) toolbar = RB.RibbonToolBar(toolbar_panel, ID_MAIN_TOOLBAR) self.toolbar = toolbar toolbar.AddTool(ID_OPEN, icons8_opened_folder_50.GetBitmap()) # "Open", toolbar.AddTool(ID_JOB, icons8_laser_beam_52.GetBitmap(), "") # toolbar.AddTool(ID_SAVE, wx.Bitmap("icons/icons8-save-50.png", wx.BITMAP_TYPE_ANY)) # "Save", windows_panel = RB.RibbonPanel(home, wx.ID_ANY, "Windows", icons8_opened_folder_50.GetBitmap()) windows = RB.RibbonButtonBar(windows_panel) windows.AddButton(ID_NAV, "Navigation", icons8_move_32.GetBitmap(), "") windows.AddButton(ID_USB, "Usb", icons8_usb_connector_50.GetBitmap(), "") windows.AddButton(ID_SPOOLER, "Spooler", icons8_route_50.GetBitmap(), "") windows.AddButton(ID_CONTROLLER, "Controller", icons8_connected_50.GetBitmap(), "") windows.AddButton(ID_PREFERENCES, "Preferences", icons8_administrative_tools_50.GetBitmap(), "") label_font = wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_LIGHT) self._bitmap_creation_dc.SetFont(label_font) self._ribbon.Realize() s = wx.BoxSizer(wx.VERTICAL) s.Add(self._ribbon, 0, wx.EXPAND) ss = wx.BoxSizer(wx.HORIZONTAL) ss.Add(self.tree, 1, wx.EXPAND) ss.Add(self.scene, 4, wx.EXPAND) s.Add(ss, 1, wx.EXPAND) panel.SetSizer(s) self.panel = panel self.CenterOnScreen() # Menu Bar self.main_menubar = wx.MenuBar() wxglade_tmp_menu = wx.Menu() # wxglade_tmp_menu.Append(ID_MENU_NEW, "New", "") # wxglade_tmp_menu.AppendSeparator() wxglade_tmp_menu.Append(ID_MENU_OPEN_PROJECT, "Open Project", "") wxglade_tmp_menu.Append(ID_MENU_IMPORT, "Import File", "") # wxglade_tmp_menu.AppendSeparator() # wxglade_tmp_menu.Append(ID_MENU_SAVE, "Save", "") # wxglade_tmp_menu.Append(ID_MENU_SAVE_AS, "Save As", "") wxglade_tmp_menu.AppendSeparator() wxglade_tmp_menu.Append(ID_MENU_EXIT, "Exit", "") self.main_menubar.Append(wxglade_tmp_menu, "File") wxglade_tmp_menu = wx.Menu() wxglade_tmp_menu.Append(ID_MENU_ZOOM_OUT, "Zoom Out", "") wxglade_tmp_menu.Append(ID_MENU_ZOOM_IN, "Zoom In", "") wxglade_tmp_menu.Append(ID_MENU_ZOOM_SIZE, "Zoom To Size", "") wxglade_tmp_menu.AppendSeparator() wxglade_tmp_menu.Append(ID_MENU_HIDE_GRID, "Hide Grid", "", wx.ITEM_CHECK) wxglade_tmp_menu.Append(ID_MENU_HIDE_GUIDES, "Hide Guides", "", wx.ITEM_CHECK) wxglade_tmp_menu.Append(ID_MENU_HIDE_FILLS, "Hide Fills", "", wx.ITEM_CHECK) self.main_menubar.Append(wxglade_tmp_menu, "View") wxglade_tmp_menu = wx.Menu() wxglade_tmp_menu_sub = wx.Menu() wxglade_tmp_menu_sub.Append(ID_MENU_ROTATE_CW, u"Rotate \u03c4/4", "") wxglade_tmp_menu_sub.Append(ID_MENU_ROTATE_CCW, u"Rotate -\u03c4/4", "") wxglade_tmp_menu_sub.Append(ID_MENU_HFLIP, "H-Flip", "") wxglade_tmp_menu_sub.Append(ID_MENU_VFLIP, "V-Flip", "") wxglade_tmp_menu.Append(wx.ID_ANY, "Transform", wxglade_tmp_menu_sub, "") self.main_menubar.Append(wxglade_tmp_menu, "Design") wxglade_tmp_menu = wx.Menu() wxglade_tmp_menu.Append(ID_MENU_PREFERENCES, "Preferences", "") wxglade_tmp_menu.Append(ID_MENU_KEYMAP, "Keymap Settings", "") wxglade_tmp_menu.Append(ID_MENU_ALIGNMENT, "Alignment Ally", "") wxglade_tmp_menu.Append(ID_MENU_NAVIGATION, "Navigation", "") wxglade_tmp_menu.Append(ID_MENU_CONTROLLER, "Controller", "") wxglade_tmp_menu.Append(ID_MENU_USB, "USB", "") wxglade_tmp_menu.Append(ID_MENU_SPOOLER, "Job Spooler", "") wxglade_tmp_menu.Append(ID_MENU_JOB, "Execute Job", "") self.main_menubar.Append(wxglade_tmp_menu, "Windows") wxglade_tmp_menu = wx.Menu() wxglade_tmp_menu.Append(ID_MENU_WEBPAGE, "Webpage", "") self.main_menubar.Append(wxglade_tmp_menu, "Help") self.SetMenuBar(self.main_menubar) # Menu Bar end self.Bind(wx.EVT_MENU, self.on_click_new, id=ID_MENU_NEW) self.Bind(wx.EVT_MENU, self.on_click_open, id=ID_MENU_OPEN_PROJECT) self.Bind(wx.EVT_MENU, self.on_click_import, id=ID_MENU_IMPORT) # self.Bind(wx.EVT_MENU, self.on_click_save, id=ID_MENU_SAVE) # self.Bind(wx.EVT_MENU, self.on_click_save_as, id=ID_MENU_SAVE_AS) self.Bind(wx.EVT_MENU, self.on_click_exit, id=ID_MENU_EXIT) self.Bind(wx.EVT_MENU, self.on_click_zoom_out, id=ID_MENU_ZOOM_OUT) self.Bind(wx.EVT_MENU, self.on_click_zoom_in, id=ID_MENU_ZOOM_IN) self.Bind(wx.EVT_MENU, self.on_click_zoom_size, id=ID_MENU_ZOOM_SIZE) self.Bind(wx.EVT_MENU, self.toggle_draw_mode(4), id=ID_MENU_HIDE_GRID) self.Bind(wx.EVT_MENU, self.toggle_draw_mode(2), id=ID_MENU_HIDE_GUIDES) self.Bind(wx.EVT_MENU, self.toggle_draw_mode(1), id=ID_MENU_HIDE_FILLS) self.Bind(wx.EVT_MENU, self.transform_rotate_right, id=ID_MENU_ROTATE_CW) self.Bind(wx.EVT_MENU, self.transform_rotate_left, id=ID_MENU_ROTATE_CCW) self.Bind(wx.EVT_MENU, self.transform_mirror_hflip, id=ID_MENU_HFLIP) self.Bind(wx.EVT_MENU, self.transform_mirror_vflip, id=ID_MENU_VFLIP) self.Bind(wx.EVT_MENU, self.open_alignment, id=ID_MENU_ALIGNMENT) self.Bind(wx.EVT_MENU, self.open_keymap, id=ID_MENU_KEYMAP) self.Bind(wx.EVT_MENU, self.open_preferences, id=ID_MENU_PREFERENCES) self.Bind(wx.EVT_MENU, self.open_navigation, id=ID_MENU_NAVIGATION) self.Bind(wx.EVT_MENU, self.open_controller, id=ID_MENU_CONTROLLER) self.Bind(wx.EVT_MENU, self.open_usb, id=ID_MENU_USB) self.Bind(wx.EVT_MENU, self.open_spooler, id=ID_MENU_SPOOLER) self.Bind(wx.EVT_MENU, self.open_job, id=ID_MENU_JOB) self.Bind(wx.EVT_MENU, self.launch_webpage, id=ID_MENU_WEBPAGE) toolbar.Bind(RB.EVT_RIBBONTOOLBAR_CLICKED, self.on_click_open, id=ID_OPEN) toolbar.Bind(RB.EVT_RIBBONTOOLBAR_CLICKED, self.open_job, id=ID_JOB) # toolbar.Bind(RB.EVT_RIBBONTOOLBAR_CLICKED, self.on_click_save, id=ID_SAVE) windows.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.open_usb, id=ID_USB) windows.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.open_navigation, id=ID_NAV) windows.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.open_controller, id=ID_CONTROLLER) windows.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.open_preferences, id=ID_PREFERENCES) windows.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.open_spooler, id=ID_SPOOLER) self.main_statusbar = self.CreateStatusBar(3) self.__set_properties() self.__do_layout() # end wxGlade self.Bind(wx.EVT_DROP_FILES, self.on_drop_file) self.Bind(wx.EVT_SIZE, self.on_size_set) self.previous_position = None self.project.elements_change_listener = self.tree_update self.project.config = wx.Config("MeerK40t") self.project.load_config() self.Bind(wx.EVT_CLOSE, self.on_close, self) self.project["usb_status", self.on_usb_status] = self self.project["control_thread", self.on_control_state] = self self.project["writer", self.on_writer_state] = self m = self.GetMenuBar().FindItemById(ID_MENU_HIDE_GRID) m.Check(self.project.draw_mode & 4 != 0) m = self.GetMenuBar().FindItemById(ID_MENU_HIDE_GUIDES) m.Check(self.project.draw_mode & 2 != 0) m = self.GetMenuBar().FindItemById(ID_MENU_HIDE_FILLS) m.Check(self.project.draw_mode & 1 != 0)
def __init__(self, parent, id=wx.ID_ANY, title="", pos=wx.DefaultPosition, size=wx.DEFAULT_FRAME_STYLE, log=None): wx.Frame.__init__(self, parent, id, title, pos, size) panel = wx.Panel(self) logger = Logger('FIT_UI') logger.add_StreamHandler() logger.add_FileHandler('Initial_test.log') self.logger = logger.logger self.parameters = {} tree = ET.parse("parameters.xml") root = tree.getroot() for child in root: for sub_child in child: self.parameters[sub_child.tag] = sub_child.test.encode('utf8') self.parameters["REPO_DIR"] = os.getcwd() self._ribbon = RB.RibbonBar(panel, style=RB.RIBBON_BAR_DEFAULT_STYLE | RB.RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS) self._bitmap_creation_dc = wx.MemoryDC() self._colour_data = wx.ColourData() self.db_user = DB_Handler('users', self.parameters, self.logger) self.db_params = DB_Handler('parameters', self.parameters, self.logger) self.db_event = DB_Handler("event", self.parameters, self.logger) self.events = [] self.fit_dict = {} home = RB.RibbonPage(self._ribbon, wx.ID_ANY, "HomePage", CreateBitmap("ribbon")) # First page toolbar_panel = RB.RibbonPanel(home, wx.ID_ANY, "Toolbar", style=RB.RIBBON_PANEL_NO_AUTO_MINIMISE | RB.RIBBON_PANEL_EXT_BUTTON) toolbar = RB.RibbonToolBar(toolbar_panel, UI_parameters.ID_MAIN_TOOLBAR) toolbar.AddTool( UI_parameters.ID_MNUUNDO, wx.ArtProvider.GetBitmap(wx.ART_UNDO, wx.ART_OTHER, wx.Size(24, 23))) toolbar.AddTool( UI_parameters.ID_MNUREDO, wx.ArtProvider.GetBitmap(wx.ART_REDO, wx.ART_OTHER, wx.Size(24, 23))) toolbar.AddSeparator() toolbar.AddTool( UI_parameters.ID_MNUFILEOPEN, wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, wx.Size(24, 23))) toolbar.AddTool( UI_parameters.ID_MNUFILESAVE, wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_OTHER, wx.Size(24, 23))) toolbar.AddTool( UI_parameters.ID_MNUFILESAVEAS, wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_OTHER, wx.Size(24, 23))) toolbar.AddTool( UI_parameters.ID_MNUFILEPRINT, wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_OTHER, wx.Size(24, 23))) toolbar.AddSeparator() toolbar.SetRows(2, 3) user_panel = RB.RibbonPanel(home, wx.ID_ANY, "User", style=RB.RIBBON_PANEL_NO_AUTO_MINIMISE | RB.RIBBON_PANEL_EXT_BUTTON) user = RB.RibbonToolBar(user_panel, wx.ID_ANY) user.AddTool( UI_parameters.ADD_User, wx.ArtProvider.GetBitmap(wx.ART_PLUS, wx.ART_OTHER, wx.Size(24, 23)), "Add User") user.AddTool( UI_parameters.DEL_User, wx.ArtProvider.GetBitmap(wx.ART_MINUS, wx.ART_OTHER, wx.Size(24, 23)), "Delete User") user.AddTool( UI_parameters.EDIT_User, wx.ArtProvider.GetBitmap(wx.ART_FIND_AND_REPLACE, wx.ART_OTHER, wx.Size(24, 23)), "Modify User") race_panel = RB.RibbonPanel(home, wx.ID_ANY, "Event", style=RB.RIBBON_PANEL_NO_AUTO_MINIMISE | RB.RIBBON_PANEL_EXT_BUTTON) race = RB.RibbonToolBar(race_panel, wx.ID_ANY) race.AddTool( UI_parameters.ADD_Event, wx.ArtProvider.GetBitmap(wx.ART_PLUS, wx.ART_OTHER, wx.Size(24, 23)), "Add Event") race.AddTool( UI_parameters.DEL_Event, wx.ArtProvider.GetBitmap(wx.ART_MINUS, wx.ART_OTHER, wx.Size(24, 23)), "Delete Event") # Second page stats_page = RB.RibbonPage(self._ribbon, wx.ID_ANY, "Statistic analyzes", CreateBitmap("eye")) stats_panel = RB.RibbonPanel(stats_page, wx.ID_ANY, "Save", CreateBitmap("selection_panel")) stats_tools = RB.RibbonToolBar(stats_panel, wx.ID_ANY) stats_tools.AddTool( UI_parameters.ID_MNUFILEOPEN, wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, wx.Size(24, 23))) stats_tools.AddTool( UI_parameters.ID_MNUFILESAVE, wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_OTHER, wx.Size(24, 23))) stats_tools.AddSeparator() stats_tools.AddTool( UI_parameters.ID_MNUFILESAVEAS, wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_OTHER, wx.Size(24, 23))) stats_tools.AddTool( UI_parameters.ID_MNUFILEPRINT, wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_OTHER, wx.Size(24, 23))) stats_tools.SetRows(2, 3) s = wx.BoxSizer(wx.VERTICAL) self.myUser = Project_frame(panel, db_user=self.db_user, db_event=self.db_event, db_params=self.db_params) s.Add(self._ribbon, 0, wx.EXPAND) s.Add(self.myUser, 1, wx.EXPAND) panel.SetSizer(s) self.panel = panel self._BindEvents(toolbar, user, race) self.SetIcon(images.mondrian.Icon) self.CenterOnScreen() self._ribbon.Realize()