def __init__(self, url, icon, title, size): super(CefApp, self).__init__([]) if cef.GetAppSetting("external_message_pump") or \ cef.GetAppSetting("multi_threaded_message_loop"): self.timer = None else: self.timer = self.createTimer() self.url, self.icon, self.title, self.size = url, icon, title, size self.main_window = MainWindow(url, icon, title, size) self.main_window.show() self.main_window.activateWindow() self.main_window.raise_() self.frame = self.main_window
def OnGotFocus(self, browser, **_): if cef.GetAppSetting("debug"): print("[qt.py] FocusHandler.OnGotFocus") self.cef_widget.setFocus() # Temporary fix no. 1 for focus issues on Linux (Issue #284) if LINUX: browser.SetFocus(True)
def focusOutEvent(self, event): # This event seems to never get called on Linux, as CEF is # stealing all focus due to Issue #284. if cef.GetAppSetting("debug"): print("[qt.py] CefWidget.focusOutEvent") if self.browser: self.browser.SetFocus(False)
def main(): freeze_support() # This generates an error.log file on error sys.excepthook = cef.ExceptHook # To shutdown all CEF processes on error settings = {} # Instead of timer loop if MAC: settings["external_message_pump"] = True # Create and launch cef browser and qt window cef.Initialize(settings) app = CefApplication(sys.argv) main_window = MainWindow() main_window.setWindowTitle("cellxgene") main_window.setUnifiedTitleAndToolBarOnMac(True) main_window.setWindowIcon(QIcon(":icon.png")) main_window.show() main_window.activateWindow() main_window.raise_() try: app.exec_() except Exception as e: raise finally: # Clean up on close if not cef.GetAppSetting("external_message_pump"): app.stopTimer() main_window.shutdownServer() del main_window # Just to be safe, similarly to "del app" del app # Must destroy app object before calling Shutdown cef.Shutdown() sys.exit(0)
def focusInEvent(self, event): # This event seems to never get called on Linux, as CEF is # stealing all focus due to Issue #284. if cef.GetAppSetting("debug"): print("[qt.py] CefWidget.focusInEvent") if self.browser: if WINDOWS: WindowUtils.OnSetFocus(self.getHandle(), 0, 0, 0) self.browser.SetFocus(True)
def OnGotFocus(self, browser, **_): if cef.GetAppSetting("debug"): print("[qt.py] FocusHandler.OnGotFocus") # Check if browser is not closing otherwise error occurs in PySide: # > RuntimeError: Internal C++ object (CefWidget) already deleted. if not browser.GetUserData("closing-browser") and self.cef_widget: self.cef_widget.setFocus() # Temporary fix no. 1 for focus issues on Linux (Issue #284) if LINUX: browser.SetFocus(True)
def main(): check_versions() sys.excepthook = cef.ExceptHook # To shutdown all CEF processes on error settings = {} cef.Initialize(settings) app = CefApplication(sys.argv) main_window = MainWindow() main_window.show() main_window.activateWindow() main_window.raise_() app.exec_() if not cef.GetAppSetting("external_message_pump"): app.stopTimer() del main_window # Just to be safe, similarly to "del app" del app # Must destroy app object before calling Shutdown cef.Shutdown()
def main(): """ See https://github.com/cztomczak/cefpython/blob/master/api/ApplicationSettings.md for mor settings """ sys.excepthook = cef.ExceptHook # To shutdown all CEF processes on error # see for more infos settings = {'auto_zooming': f'{ZOOM_FACTOR}'} cef.Initialize(settings) app = CefApplication(sys.argv) main_window = MainWindow() main_window.show() main_window.activateWindow() main_window.raise_() app.exec_() if not cef.GetAppSetting("external_message_pump"): app.stopTimer() del main_window # Just to be safe, similarly to "del app" del app # Must destroy app object before calling Shutdown cef.Shutdown()
def main(): check_versions() sys.excepthook = cef.ExceptHook # To shutdown all CEF processes on error settings = {} if MAC: # Issue #442 requires enabling message pump on Mac # in Qt example. Calling cef.DoMessageLoopWork in a timer # doesn't work anymore. settings["external_message_pump"] = True cef.Initialize(settings) app = CefApplication(sys.argv) main_window = MainWindow() main_window.show() main_window.activateWindow() main_window.raise_() app.exec_() if not cef.GetAppSetting("external_message_pump"): app.stopTimer() del main_window # Just to be safe, similarly to "del app" del app # Must destroy app object before calling Shutdown cef.Shutdown()
def __init__(self, args): super(CefApplication, self).__init__(args) if not cef.GetAppSetting("external_message_pump"): self.timer = self.createTimer()
def OnSetFocus(self, **_): if cef.GetAppSetting("debug"): print("[qt.py] FocusHandler.OnSetFocus")
def OnTakeFocus(self, **_): if cef.GetAppSetting("debug"): log.info("[qt.py] FocusHandler.OnTakeFocus")