コード例 #1
0
ファイル: shellInfoDialog.py プロジェクト: ysalmon/pyzo
 def setInfo(self, info=None):
     """  Set the shell info struct, and use it to update the widgets.
     Not via init, because this function also sets the tab name.
     """
     
     # If info not given, use default as specified by the KernelInfo struct
     if info is None:
         info = KernelInfo()
         # Name
         n = self.parent().parent().count()
         if n > 1:
             info.name = "Shell config %i" % n
     
     # Store info
     self._info = info
     
     # Set widget values according to info
     try:
         for key in info:
             widget = self._shellInfoWidgets.get(key, None)
             if widget is not None:
                 widget.setTheText(info[key])
     
     except Exception as why:
         print("Error setting info in shell config:", why)
         print(info)
コード例 #2
0
ファイル: shellInfoDialog.py プロジェクト: operade/pyzo
    def setInfo(self, info=None):
        """  Set the shell info struct, and use it to update the widgets.
        Not via init, because this function also sets the tab name.
        """

        # If info not given, use default as specified by the KernelInfo struct
        if info is None:
            info = KernelInfo()
            # Name
            n = self.parent().parent().count()
            if n > 1:
                info.name = "Shell config %i" % n

        # Store info
        self._info = info

        # Set widget values according to info
        try:
            for key in info:
                widget = self._shellInfoWidgets.get(key, None)
                if widget is not None:
                    widget.setTheText(info[key])

        except Exception as why:
            print("Error setting info in shell config:", why)
            print(info)
コード例 #3
0
 def useFound(self):
     # Set newfound interpreter
     if self._the_exe:
         configs = pyzo.config.shellConfigs2
         if not configs:
             from pyzo.core.kernelbroker import KernelInfo
             pyzo.config.shellConfigs2.append(KernelInfo())
         configs[0].exe = self._the_exe
         self.restart_shell()
     self.refresh()
コード例 #4
0
ファイル: main.py プロジェクト: stonebig/pyzo
    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()
コード例 #5
0
    def __init__(self, parent=None, locale=None):
        '''
        Important: do *all* inits here.  Do *not* call MainWindow.__init__.
        
        This allows us complete control over all aspects of the startup process.

        This method is based on pyzo code
        Copyright (C) 2013-2018 by Almar Klein.
        
        '''
        #
        # pylint: disable=non-parent-init-called, super-init-not-called
        QtWidgets.QMainWindow.__init__(self, parent)
        #
        # Do **not** call MainWindow.__init__: it calls _populate!
        #
        self.setObjectName('MainWindowShim')
        self.monkey_patch_leo()
        pyzo.loadConfig()
        # To be replaced by LeoPyzoConfig.loadConfig.
        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.setWindowTitle('Leo Main Window')
        pyzo.core.main.loadAppIcons()
        g.app.gui.attachLeoIcon(self)
        #
        # Restore window geometry before drawing for the first time.
        self.resize(800, 600)  # default size
        self.restoreGeometry()
        #
        # This just slows down the initial draw.
        # self.setCentralWidget(SplashShim(parent))
        #
        # These do nothing, even when use_shell is True.
        # self.setStyleSheet("QMainWindow { background-color: #268bd2;}")
        # self.setStyleSheet("QMainWindow { background-color: red;}")
        #
        # Show empty window and disable updates for a while
        if self.initial_draw:
            self.show()
            self.paintNow()
        self.setUpdatesEnabled(False)
        #
        # Set locale of main widget, for translate.
        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 pyzo icons and fonts.
        pyzo.core.main.loadIcons()
        pyzo.core.main.loadFonts()
        #
        # Set qt style and test success
        self.setQtStyle(None)  # None means init!
        #
        # Populate the window (imports more code)
        self._populate()
        #
        # Revert to normal background, and enable updates
        self.setStyleSheet('')
        # Required.
        self.setUpdatesEnabled(True)
        #
        # Restore window state, force updating, and restore again
        self.restoreState()
        if not self.initial_draw:
            self.show()
        self.paintNow()
        self.restoreState()
        #
        # Create new shell config if there is None
        if not pyzo.config.shellConfigs2:
            from pyzo.core.kernelbroker import KernelInfo
            pyzo.config.shellConfigs2.append(KernelInfo())
        #
        # EKR: Set background.
        if getattr(pyzo.config.settings, 'dark_theme', None):
            bg = getattr(pyzo.config.settings, 'dark_background', '#657b83')
            # Default: solarized base00
            try:
                self.setStyleSheet("background: %s" % bg)
            except Exception:
                g.pr('oops: MainWindow.__init__')
        #
        # Put the focus on editor
        e = pyzo.editors.getCurrentEditor()
        if e is not None:
            e.setFocus()
        #
        # Handle any actions
        pyzo.core.commandline.handle_cmd_args()
コード例 #6
0
ファイル: pyzo_in_leo.py プロジェクト: wrapperband/leo-editor
    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()