def _InitComponents(self): self.tabs = fnb.FlatNotebook(self, wx.ID_ANY, agwStyle=fnb.FNB_NODRAG|fnb.FNB_X_ON_TAB) # You also have to set the wx.WANTS_CHARS style for # all parent panels/controls, if it's deeply embedded. self.tabs.SetWindowStyleFlag(wx.WANTS_CHARS) ctrl1 = chrome.ChromeCtrl(self.tabs, useTimer=True, url="wikipedia.org") ctrl1.GetNavigationBar().GetUrlCtrl().SetEditable(False) ctrl1.GetNavigationBar().GetBackButton().SetBitmapLabel( wx.Bitmap(os.path.join(os.path.dirname(os.path.abspath(__file__)), "back.png"), wx.BITMAP_TYPE_PNG)) ctrl1.GetNavigationBar().GetForwardButton().SetBitmapLabel( wx.Bitmap(os.path.join(os.path.dirname(os.path.abspath(__file__)), "forward.png"), wx.BITMAP_TYPE_PNG)) ctrl1.GetNavigationBar().GetReloadButton().SetBitmapLabel( wx.Bitmap(os.path.join(os.path.dirname(os.path.abspath(__file__)), "reload_page.png"), wx.BITMAP_TYPE_PNG)) self.tabs.AddPage(ctrl1, "Wikipedia") ctrl2 = chrome.ChromeCtrl(self.tabs, useTimer=True, url="google.com", hasNavBar=False) self.tabs.AddPage(ctrl2, "Google") ctrl3 = chrome.ChromeCtrl(self.tabs, useTimer=True, url="greenpeace.org") ctrl3.SetNavigationBar(CustomNavigationBar(ctrl3)) self.tabs.AddPage(ctrl3, "Greenpeace")
def OnSelChanged(self, event): self.item = event.GetItem() url = self.tree.GetItemText(self.item) if url and url != ROOT_NAME: cefPanel = chrome.ChromeCtrl(self.tabs, useTimer=True, url=str(url)) self.tabs.AddPage(cefPanel, url) self.tabs.SetSelection(self.tabs.GetPageCount() - 1) event.Skip()
def __init__(self, parent, title, url, **kwargs): # Setting the settings self.main_config = kwargs.get('main_config') self.gui_settings = kwargs.get('gui_settings') self.loaded_modules = kwargs.get('loaded_modules') self.queue = kwargs.get('queue') self.settings_window = None wx.Frame.__init__(self, parent, title=title, size=self.gui_settings.get('size')) # Set window style styles = wx.DEFAULT_FRAME_STYLE if self.gui_settings.get('on_top', False): log.info("Application is on top") styles = styles | wx.STAY_ON_TOP self.SetFocus() self.SetWindowStyle(styles) # Creating categories for gui log.debug("Sorting modules to categories") self.sorted_categories = create_categories(self.loaded_modules) # Creating main gui window vbox = wx.BoxSizer(wx.VERTICAL) self.toolbar = MainMenuToolBar(self, main_class=self) self.browser_window = chromectrl.ChromeCtrl(self, useTimer=False, url=str(url), hasNavBar=False) vbox.Add(self.toolbar, 0, wx.EXPAND) vbox.Add(self.browser_window, 1, wx.EXPAND) # Set events self.Bind(wx.EVT_CLOSE, self.on_close) # Show window after creation self.SetSizer(vbox) self.Show(True) # Show update dialog if new version found if self.main_config['update']: dialog = wx.MessageDialog( self, message="There is new version, do you want to update?", caption="New Update Available", style=wx.YES_NO | wx.YES_DEFAULT, pos=wx.DefaultPosition) response = dialog.ShowModal() if response == wx.ID_YES: webbrowser.open(self.main_config['update_url'])
def _InitComponents(self): self.tabs = fnb.FlatNotebook(self, wx.ID_ANY, agwStyle=fnb.FNB_NODRAG | fnb.FNB_X_ON_TAB) ctrl1 = chrome.ChromeCtrl(self.tabs, useTimer=True, url="wikipedia.org") ctrl1.GetNavigationBar().GetUrlCtrl().SetEditable(False) ctrl1.GetNavigationBar().GetBackButton().SetBitmapLabel( wx.Bitmap( os.path.join(os.path.dirname(os.path.abspath(__file__)), "back.png"), wx.BITMAP_TYPE_PNG)) ctrl1.GetNavigationBar().GetForwardButton().SetBitmapLabel( wx.Bitmap( os.path.join(os.path.dirname(os.path.abspath(__file__)), "forward.png"), wx.BITMAP_TYPE_PNG)) ctrl1.GetNavigationBar().GetReloadButton().SetBitmapLabel( wx.Bitmap( os.path.join(os.path.dirname(os.path.abspath(__file__)), "reload_page.png"), wx.BITMAP_TYPE_PNG)) self.tabs.AddPage(ctrl1, "Wikipedia") ctrl2 = chrome.ChromeCtrl(self.tabs, useTimer=True, url="google.com", hasNavBar=False) self.tabs.AddPage(ctrl2, "Google") ctrl3 = chrome.ChromeCtrl(self.tabs, useTimer=True, url="greenpeace.org") ctrl3.SetNavigationBar(CustomNavigationBar(ctrl3)) self.tabs.AddPage(ctrl3, "Greenpeace")
def __init__(self, parent, title, url, **kwargs): # Setting the settings self.main_config = kwargs.get('main_config') self.gui_settings = kwargs.get('gui_settings') self.loaded_modules = kwargs.get('loaded_modules') self.queue = kwargs.get('queue') self.settings_window = None self.status_frame = None self.browser = None self.first_readjust = False wx.Frame.__init__(self, parent, title=title, size=self.gui_settings.get('size'), pos=self.gui_settings.get('position')) # Set window style if self.gui_settings.get('transparency') < 100: log.info("Application is transparent") self.SetTransparent(self.gui_settings['transparency'] * 2.55) if self.gui_settings.get('borderless', False): log.info("Application is in borderless mode") styles = wx.CLIP_CHILDREN | wx.BORDER_NONE | wx.FRAME_SHAPED else: styles = wx.DEFAULT_FRAME_STYLE if self.gui_settings.get('on_top', False): log.info("Application is on top") styles = styles | wx.STAY_ON_TOP self.styles = styles self.SetFocus() self.SetWindowStyle(styles) # Creating categories for gui log.debug("Sorting modules to categories") self.sorted_categories = create_categories(self.loaded_modules) # Creating main gui window vbox = wx.BoxSizer(wx.VERTICAL) self.toolbar = MainMenuToolBar(self, main_class=self) vbox.Add(self.toolbar, 0, wx.EXPAND) self.status_frame = StatusFrame(self) self.status_frame.load() vbox.Add(self.status_frame, 0, wx.EXPAND) if self.main_config['config']['gui']['show_counters']: if self.status_frame.chats: self.status_frame.Show(True) self.status_frame.Fit() self.status_frame.Layout() if self.gui_settings['show_browser']: if HAS_CHROME: browser_settings = {'application_cache_disabled': True} self.browser = browser.ChromeCtrl( self, useTimer=False, url=str(url), hasNavBar=False, browserSettings=browser_settings) if self.main_config['config']['system']['testing_mode']: self.browser2 = browser.ChromeCtrl( self, useTimer=False, url=str(url).replace('/gui', ''), hasNavBar=False, browserSettings=browser_settings) vbox.Add(self.browser2, 1, wx.EXPAND) else: self.browser = browser.WebView.New(parent=self, url=url, name='LalkaWebViewGui') if self.main_config['config']['system']['testing_mode']: self.browser2 = browser.WebView.New( parent=self, url=str(url).replace('/gui', ''), name='LalkaWebViewGui2') vbox.Add(self.browser2, 1, wx.EXPAND) vbox.Add(self.browser, 1, wx.EXPAND) # Set events self.Bind(wx.EVT_CLOSE, self.on_close) self.Bind(EVT_STATUS_CHANGE, self.process_status_change) self.Bind(wx.EVT_ACTIVATE, self.activate) # Show window after creation self.SetSizer(vbox) if not self.gui_settings['show_browser']: self.Layout() self.Fit() current_size = self.GetSize() max_height = self.status_frame.GetSize( )[1] + self.toolbar.GetBestSize()[1] if current_size[1] != max_height: self.SetSize(wx.Size(current_size[0], max_height)) self.Show(True) # Show update dialog if new version found if self.main_config['update']: dialog = wx.MessageDialog( self, message="There is new version, do you want to update?", caption="New Update Available", style=wx.YES_NO | wx.YES_DEFAULT, pos=wx.DefaultPosition) response = dialog.ShowModal() if response == wx.ID_YES: webbrowser.open(self.main_config['update_url'])