def BindEvents(self, bars): rb_panel, rb_panel2 = bars # toolbar panel ext button click rb_panel.Bind(RB.EVT_RIBBONPANEL_EXTBUTTON_ACTIVATED, self.OnExtButton) # process events in frame msg loop # normal toolbar click self.Bind(RB.EVT_RIBBONTOOLBAR_CLICKED, self.OnToolClick, id=ID_BAR_FOO) # toggle toolbar click self.Bind(RB.EVT_RIBBONTOOLBAR_CLICKED, self.OnToogleClick, id=ID_BAR_TOGGLE) self.Bind(RB.EVT_RIBBONTOOLBAR_CLICKED, self.OnToogleClick, id=ID_BAR_TOGGLE2) # hybrid button, dropdown and menu click self.Bind(RB.EVT_RIBBONTOOLBAR_CLICKED, self.OnToolClick, id=wx.ID_NEW) self.Bind(RB.EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED, self.OnToolDropdown, id=wx.ID_NEW) self.Bind(wx.EVT_MENU, self.OnMenuClick, id=wx.ID_NEW) # # self.Bind(wx.EVT_BUTTON, self.OnColourGalleryButton, id=ID_SECONDARY_COLOUR) # if utils.isWin32(): self.Bind(wx.EVT_ICONIZE, self.onIconify) self.Bind(wx.EVT_CLOSE, self.onClose)
def on_close(self, event): ''' Destroy the taskbar icon and the frame ''' if utils.isWin32(): self._tbIcon.RemoveIcon() self._tbIcon.Destroy() self.Destroy()
def init_browser(self): if self.browser is not None: return self.browser sw, _ = wx.DisplaySize() s = self.parent.GetSize() p = self.parent.GetPosition() drv_path = './bin/chromedriver' if utils.isWin32(): drv_path = './bin/chromedriver.exe' self.browser = drv = webdriver.Chrome(executable_path=drv_path) drv.set_window_position(p.x + s.width, p.y) drv.set_window_size(600, s.height) return drv
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 bind_events(self, bars=None): # bar0, bar1 = bars # toggle toolbar click for btn_id in self.toggles_ids: self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.on_toogle_click, id=btn_id) self.Bind(RB.EVT_RIBBONBAR_PAGE_CHANGING, self.on_page_changing, id=ID_RIBBON) self.Bind(RB.EVT_RIBBONBAR_PAGE_CHANGED, self.on_page_changed, id=ID_RIBBON) #self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.poolpanel.statpanel.onAddRow, id=ID_IP_SETTING) self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.on_setting_click, id=ID_IP_SETTING) if utils.isWin32(): self.Bind(wx.EVT_ICONIZE, self.on_iconify) self.Bind(wx.EVT_CLOSE, self.on_close)
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())