def run(self): chromectrl.Initialize() url = ':'.join([self.url, str(self.port)]) app = wx.App( False ) # Create a new app, don't redirect stdout/stderr to a window. self.gui = ChatGui(None, "LalkaChat", url, **self.kwargs) # A Frame is a top-level window. app.MainLoop() self.quit()
def OnClose(self, event): self.Destroy() class CustomNavigationBar(chrome.NavigationBar): def _LayoutComponents(self): sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.url, 1, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 12) sizer.Add(self.GetBackButton(), 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 0) sizer.Add(self.GetForwardButton(), 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 0) # in this example we dont want reload button self.GetReloadButton().Hide() self.SetSizer(sizer) self.Fit() if __name__ == '__main__': chrome.Initialize() print('sample3.py: wx.version=%s' % wx.version()) app = wx.PySimpleApp() MainFrame().Show() app.MainLoop() # Important: do the wx cleanup before calling Shutdown. del app chrome.Shutdown()
# On Mac the code after app.MainLoop() never executes, so # need to call CEF shutdown here. if platform.system() == "Darwin": chrome.Shutdown() wx.GetApp().Exit() class MyApp(wx.App): def OnInit(self): frame = MainFrame() self.SetTopWindow(frame) frame.Show() return True if __name__ == '__main__': chrome.Initialize({ "debug": True, "log_file": "debug.log", "log_severity": chrome.cefpython.LOGSEVERITY_INFO, # "cache_path": "webcache/", }) print('[sample1.py] wx.version=%s' % wx.version()) app = MyApp(False) app.MainLoop() # Important: do the wx cleanup before calling Shutdown del app # On Mac Shutdown is called in OnClose if platform.system() in ["Linux", "Windows"]: chrome.Shutdown()
size=(1024, 768)) self.cefWindow = chrome.ChromeWindow( self, url=os.path.join(os.path.dirname(os.path.abspath(__file__)), "sample1.html")) sizer = wx.BoxSizer() sizer.Add(self.cefWindow, 1, wx.EXPAND, 0) self.SetSizer(sizer) self.Bind(wx.EVT_CLOSE, self.OnClose) def OnClose(self, event): self.Destroy() if __name__ == '__main__': chrome.Initialize({ "debug": True, "log_severity": chrome.cefpython.LOGSEVERITY_INFO, "release_dcheck_enabled": True, }) print('[sample1.py] wx.version=%s' % wx.version()) app = wx.PySimpleApp() MainFrame().Show() app.MainLoop() # Important: do the wx cleanup before calling Shutdown. del app chrome.Shutdown()