def event(self, event): if isinstance(event, QtGui.QFileOpenEvent): fname = str(event.file()) if fname and fname != 'pyzo': sys.argv[1:] = [] sys.argv.append(fname) res = commandline.handle_cmd_args() if not commandline.is_our_server_running(): print(res) sys.exit() return QtGui.QApplication.event(self, event)
if sys.version < '3': raise RuntimeError('Pyzo requires Python 3.x to run.') # Import yoton as an absolute package from pyzo import yotonloader from pyzo.util import paths # If there already is an instance of Pyzo, and the user is trying an # Pyzo command, we should send the command to the other process and quit. # We do this here, were we have not yet loaded Qt, so we are very light. from pyzo.core import commandline if commandline.is_our_server_running(): print('Started our command server') else: # Handle command line args now res = commandline.handle_cmd_args() if res: print(res) sys.exit() else: # No args, proceed with starting up print('Our command server is *not* running') from pyzo.util import zon as ssdf # zon is ssdf-light from pyzo.util.qt import QtCore, QtGui # Import language/translation tools from pyzo.util._locale import translate, setLanguage # Set environ to let kernel know some stats about us
def __init__(self, parent=None, locale=None): QtWidgets.QMainWindow.__init__(self, parent) self._closeflag = 0 # Used during closing/restarting # Init window title and application icon # Set title to something nice. On Ubuntu 12.10 this text is what # is being shown at the fancy title bar (since it's not properly # updated) self.setMainTitle() loadAppIcons() self.setWindowIcon(pyzo.icon) # Restore window geometry before drawing for the first time, # such that the window is in the right place self.resize(800, 600) # default size self.restoreGeometry() # Show splash screen (we need to set our color too) w = SplashWidget(self, distro="no distro") self.setCentralWidget(w) self.setStyleSheet("QMainWindow { background-color: #268bd2;}") # Show empty window and disable updates for a while self.show() self.paintNow() self.setUpdatesEnabled(False) # Determine timeout for showing splash screen splash_timeout = time.time() + 1.0 # Set locale of main widget, so that qt strings are translated # in the right way if locale: self.setLocale(locale) # Store myself pyzo.main = self # Init dockwidget settings self.setTabPosition(QtCore.Qt.AllDockWidgetAreas, QtWidgets.QTabWidget.South) self.setDockOptions(QtWidgets.QMainWindow.AllowNestedDocks | QtWidgets.QMainWindow.AllowTabbedDocks # | QtWidgets.QMainWindow.AnimatedDocks ) # Set window atrributes self.setAttribute(QtCore.Qt.WA_AlwaysShowToolTips, True) # Load icons and fonts loadIcons() loadFonts() # Set qt style and test success self.setQtStyle(None) # None means init! # Hold the splash screen if needed while time.time() < splash_timeout: QtWidgets.qApp.flush() QtWidgets.qApp.processEvents() time.sleep(0.05) # Populate the window (imports more code) self._populate() # Revert to normal background, and enable updates self.setStyleSheet("") self.setUpdatesEnabled(True) # Restore window state, force updating, and restore again self.restoreState() self.paintNow() self.restoreState() # Present user with wizard if he/she is new. if False: # pyzo.config.state.newUser: from pyzo.util.pyzowizard import PyzoWizard w = PyzoWizard(self) w.show( ) # Use show() instead of exec_() so the user can interact with pyzo # Create new shell config if there is None if not pyzo.config.shellConfigs2: from pyzo.core.kernelbroker import KernelInfo pyzo.config.shellConfigs2.append(KernelInfo()) # Focus on editor e = pyzo.editors.getCurrentEditor() if e is not None: e.setFocus() # Handle any actions commandline.handle_cmd_args()
raise RuntimeError('Pyzo requires Pyzolib 0.2.5 or higher.') elif pyzolib.__version__ < '0.2.9': print('Warning: pyzolib 0.2.9 is recommended to run Pyzo.') # Import yoton as an absolute package from pyzo import yotonloader # If there already is an instance of Pyzo, and the user is trying an # Pyzo command, we should send the command to the other process and quit. # We do this here, were we have not yet loaded Qt, so we are very light. from pyzo.core import commandline if commandline.is_our_server_running(): print('Started our command server') else: # Handle command line args now res = commandline.handle_cmd_args() if res: print(res) sys.exit() else: # No args, proceed with starting up print('Our command server is *not* running') from pyzolib import ssdf, paths from pyzolib.qt import QtCore, QtGui # Import language/translation tools from pyzo.util._locale import translate, setLanguage # Set environ to let kernel know some stats about us
def __init__(self, parent=None, locale=None): QtWidgets.QMainWindow.__init__(self, parent) self._closeflag = 0 # Used during closing/restarting # Init window title and application icon # Set title to something nice. On Ubuntu 12.10 this text is what # is being shown at the fancy title bar (since it's not properly # updated) self.setMainTitle() loadAppIcons() self.setWindowIcon(pyzo.icon) # Restore window geometry before drawing for the first time, # such that the window is in the right place self.resize(800, 600) # default size self.restoreGeometry() # Show splash screen (we need to set our color too) w = SplashWidget(self, distro='no distro') self.setCentralWidget(w) self.setStyleSheet("QMainWindow { background-color: #268bd2;}") # Show empty window and disable updates for a while self.show() self.paintNow() self.setUpdatesEnabled(False) # Determine timeout for showing splash screen splash_timeout = time.time() + 1.0 # Set locale of main widget, so that qt strings are translated # in the right way if locale: self.setLocale(locale) # Store myself pyzo.main = self # Init dockwidget settings self.setTabPosition(QtCore.Qt.AllDockWidgetAreas,QtWidgets.QTabWidget.South) self.setDockOptions( QtWidgets.QMainWindow.AllowNestedDocks | QtWidgets.QMainWindow.AllowTabbedDocks #| QtWidgets.QMainWindow.AnimatedDocks ) # Set window atrributes self.setAttribute(QtCore.Qt.WA_AlwaysShowToolTips, True) # Load icons and fonts loadIcons() loadFonts() # Set qt style and test success self.setQtStyle(None) # None means init! # Hold the splash screen if needed while time.time() < splash_timeout: QtWidgets.qApp.flush() QtWidgets.qApp.processEvents() time.sleep(0.05) # Populate the window (imports more code) self._populate() # Revert to normal background, and enable updates self.setStyleSheet('') self.setUpdatesEnabled(True) # Restore window state, force updating, and restore again self.restoreState() self.paintNow() self.restoreState() # Present user with wizard if he/she is new. if False: # pyzo.config.state.newUser: from pyzo.util.pyzowizard import PyzoWizard w = PyzoWizard(self) w.show() # Use show() instead of exec_() so the user can interact with pyzo # Create new shell config if there is None if not pyzo.config.shellConfigs2: from pyzo.core.kernelbroker import KernelInfo pyzo.config.shellConfigs2.append( KernelInfo() ) # Focus on editor e = pyzo.editors.getCurrentEditor() if e is not None: e.setFocus() # Handle any actions commandline.handle_cmd_args()
def main_window_ctor(self): """ Simulate MainWindow.__init__(). This code, included commented-out code, is based on pyzo. Copyright (C) 2013-2019 by Almar Klein. """ # print('\nBEGIN main_window_ctor\n') # EKR:change. New imports import pyzo.core.main as main from pyzo.core import commandline # EKR:change: was self. main_window = g.app.gui.main_window # EKR:change. # QtWidgets.QMainWindow.__init__(self, parent) main_window._closeflag = 0 # Used during closing/restarting # EKR:change. # # Init window title and application icon # self.setMainTitle() # EKR:change. main.loadAppIcons() pyzo.icon = g.app.gui.appIcon # Don't patch this now. It might be a good indicator. # pyzo.iconRunning = g.app.gui.appIcon # loadAppIcons() # EKR:change. # self.setWindowIcon(pyzo.icon) # EKR:change. # Restore window geometry. # self.resize(800, 600) # default size # self.restoreGeometry() # EKR:change. # Show splash screen (we need to set our color too) # w = SplashWidget(self, distro='no distro') # EKR:change. # self.setCentralWidget(w) # EKR:change. # self.setStyleSheet("QMainWindow { background-color: #268bd2;}") # Show empty window and disable updates for a while # EKR:change. # self.show() # self.paintNow() # self.setUpdatesEnabled(False) # EKR:change. # Determine timeout for showing splash screen # splash_timeout = time.time() + 1.0 # EKR:change. # Set locale of main widget, so that qt strings are translated # in the right way # if locale: # self.setLocale(locale) # Set pyzo.main. pyzo.main = main_window # EKR:change-Add do-nothing methods. pyzo.main.setMainTitle = g.TracingNullObject( tag='pyzo.main.setMainTitle()') pyzo.main.restart = g.TracingNullObject(tag='pyzo.main.restart()') # Init dockwidget settings main_window.setTabPosition(QtCore.Qt.AllDockWidgetAreas, QtWidgets.QTabWidget.South) main_window.setDockOptions(QtWidgets.QMainWindow.AllowNestedDocks | QtWidgets.QMainWindow.AllowTabbedDocks #| QtWidgets.QMainWindow.AnimatedDocks ) # Set window atrributes main_window.setAttribute(QtCore.Qt.WA_AlwaysShowToolTips, True) # EKR:change. # Load icons and fonts main.loadIcons() main.loadFonts() # loadIcons() # loadFonts() # EKR:change. # # Set qt style and test success # self.setQtStyle(None) # None means init! # EKR:change. # # Hold the splash screen if needed # while time.time() < splash_timeout: # QtWidgets.qApp.flush() # QtWidgets.qApp.processEvents() # time.sleep(0.05) # EKR:change. # Populate the window (imports more code) self.main_window_populate() # self._populate() # EKR:change: new code. self.load_all_pyzo_docks() # EKR:change. # Revert to normal background, and enable updates main_window.setStyleSheet('') main_window.setUpdatesEnabled(True) # EKR:change. Could this be a problem? # # Restore window state, force updating, and restore again # self.restoreState() # self.paintNow() # self.restoreState() # EKR:change. # Present user with wizard if he/she is new. # if pyzo.config.state.newUser: # from pyzo.util.pyzowizard import PyzoWizard # w = PyzoWizard(self) # w.show() # Use show() instead of exec_() so the user can interact with pyzo # EKR:change # # Create new shell config if there is None # if not pyzo.config.shellConfigs2: # from pyzo.core.kernelbroker import KernelInfo # pyzo.config.shellConfigs2.append( KernelInfo() ) from pyzo.core.kernelbroker import KernelInfo # pyzo.config.shellConfigs2.append( KernelInfo() ) pyzo.config.shellConfigs2 = [KernelInfo()] # EKR:change Set background. # bg = getattr(pyzo.config.settings, 'dark_background', '#657b83') # # Default: solarized base00 # try: # self.setStyleSheet(f"background: {bg}") # except Exception: # g.es_exception() # Focus on editor e = pyzo.editors.getCurrentEditor() if e is not None: e.setFocus() # Handle any actions commandline.handle_cmd_args()