コード例 #1
0
ファイル: main.py プロジェクト: stonebig/pyzo
    def _populate(self):

        # Delayed imports
        from pyzo.core.editorTabs import EditorTabs
        from pyzo.core.shellStack import ShellStackWidget
        from pyzo.core import codeparser
        from pyzo.core.history import CommandHistory
        from pyzo.tools import ToolManager

        # Instantiate tool manager
        pyzo.toolManager = ToolManager()

        # Check to install conda now ...
        # from pyzo.util.bootstrapconda import check_for_conda_env
        # check_for_conda_env()

        # Instantiate and start source-code parser
        if pyzo.parser is None:
            pyzo.parser = codeparser.Parser()
            pyzo.parser.start()

        # Create editor stack and make the central widget
        pyzo.editors = EditorTabs(self)
        self.setCentralWidget(pyzo.editors)

        # Create floater for shell
        self._shellDock = dock = QtWidgets.QDockWidget(self)
        if pyzo.config.settings.allowFloatingShell:
            dock.setFeatures(dock.DockWidgetMovable | dock.DockWidgetFloatable)
        else:
            dock.setFeatures(dock.DockWidgetMovable)
        dock.setObjectName("shells")
        dock.setWindowTitle("Shells")
        self.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock)

        # Create shell stack
        pyzo.shells = ShellStackWidget(self)
        dock.setWidget(pyzo.shells)

        # Initialize command history
        pyzo.command_history = CommandHistory("command_history.py")

        # Create the default shell when returning to the event queue
        callLater(pyzo.shells.addShell)

        # Create status bar
        self.setStatusBar(StatusBar())
        # show or hide
        self.statusBar().setVisible(pyzo.config.view.showStatusbar)

        # Create menu
        from pyzo.core import menu

        pyzo.keyMapper = menu.KeyMapper()
        menu.buildMenus(self.menuBar())

        # Add the context menu to the editor
        pyzo.editors.addContextMenu()
        pyzo.shells.addContextMenu()

        # Load tools
        if pyzo.config.state.newUser and not pyzo.config.state.loadedTools:
            pyzo.toolManager.loadTool("pyzosourcestructure")
            pyzo.toolManager.loadTool("pyzofilebrowser", "pyzosourcestructure")
        elif pyzo.config.state.loadedTools:
            for toolId in pyzo.config.state.loadedTools:
                pyzo.toolManager.loadTool(toolId)
コード例 #2
0
    def _populate(self):

        # Delayed imports
        from pyzo.core.editorTabs import EditorTabs
        from pyzo.core.shellStack import ShellStackWidget
        from pyzo.core import codeparser
        from pyzo.tools import ToolManager

        # Instantiate tool manager
        pyzo.toolManager = ToolManager()

        # Check to install conda now ...
        #from pyzo.util.bootstrapconda import check_for_conda_env
        #check_for_conda_env()

        # Instantiate and start source-code parser
        if pyzo.parser is None:
            pyzo.parser = codeparser.Parser()
            pyzo.parser.start()

        # Create editor stack and make the central widget
        pyzo.editors = EditorTabs(self)
        self.setCentralWidget(pyzo.editors)

        # Create floater for shell
        self._shellDock = dock = QtGui.QDockWidget(self)
        dock.setFeatures(dock.DockWidgetMovable)
        dock.setObjectName('shells')
        dock.setWindowTitle('Shells')
        self.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock)

        # Create shell stack
        pyzo.shells = ShellStackWidget(self)
        dock.setWidget(pyzo.shells)

        # Create the default shell when returning to the event queue
        callLater(pyzo.shells.addShell)

        # Create statusbar
        if pyzo.config.view.showStatusbar:
            pyzo.status = self.statusBar()
        else:
            pyzo.status = None
            self.setStatusBar(None)

        # Create menu
        from pyzo.core import menu
        pyzo.keyMapper = menu.KeyMapper()
        menu.buildMenus(self.menuBar())

        # Add the context menu to the editor
        pyzo.editors.addContextMenu()
        pyzo.shells.addContextMenu()

        # Load tools
        if pyzo.config.state.newUser and not pyzo.config.state.loadedTools:
            pyzo.toolManager.loadTool('pyzosourcestructure')
            pyzo.toolManager.loadTool('pyzofilebrowser', 'pyzosourcestructure')
        elif pyzo.config.state.loadedTools:
            for toolId in pyzo.config.state.loadedTools:
                pyzo.toolManager.loadTool(toolId)
コード例 #3
0
        def _populate(self):
            '''
            A monkey-patched version of MainWindow._populate.
            
            Copyright (C) 2013-2018, the Pyzo development team
            '''
            if g: g.pr('\nBEGIN PATCHED MainWindow._populate')

            # Delayed imports
            from pyzo.core.editorTabs import EditorTabs
            from pyzo.core.shellStack import ShellStackWidget
            from pyzo.core import codeparser
            from pyzo.core.history import CommandHistory
            from pyzo.tools import ToolManager

            # Instantiate tool manager
            pyzo.toolManager = ToolManager()

            # Check to install conda now ...
            #from pyzo.util.bootstrapconda import check_for_conda_env
            #check_for_conda_env()

            # Instantiate and start source-code parser
            if pyzo.parser is None:
                pyzo.parser = codeparser.Parser()
                pyzo.parser.start()

            # Create editor stack and make the central widget
            pyzo.editors = EditorTabs(self)
            self.setCentralWidget(pyzo.editors)
            # EKR: QMainWindow.setCentralWidget

            # Create floater for shell
            self._shellDock = dock = QtWidgets.QDockWidget(self)
            if pyzo.config.settings.allowFloatingShell:
                dock.setFeatures(dock.DockWidgetMovable
                                 | dock.DockWidgetFloatable)
            else:
                dock.setFeatures(dock.DockWidgetMovable)
            dock.setObjectName('shells')
            dock.setWindowTitle('Shells')
            self.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock)

            # Create shell stack
            pyzo.shells = ShellStackWidget(self)
            dock.setWidget(pyzo.shells)

            # Initialize command history
            pyzo.command_history = CommandHistory('command_history.py')

            # Create the default shell when returning to the event queue
            callLater(pyzo.shells.addShell)

            # Create statusbar
            if pyzo.config.view.showStatusbar:
                pyzo.status = self.statusBar()
            else:
                pyzo.status = None
                self.setStatusBar(None)

            # Create menu
            from pyzo.core import menu
            pyzo.keyMapper = menu.KeyMapper()
            menu.buildMenus(self.menuBar())

            # Add the context menu to the editor
            pyzo.editors.addContextMenu()
            pyzo.shells.addContextMenu()

            # Load tools
            if pyzo.config.state.newUser and not pyzo.config.state.loadedTools:
                pyzo.toolManager.loadTool('pyzosourcestructure')
                pyzo.toolManager.loadTool('pyzofilebrowser',
                                          'pyzosourcestructure')
            elif pyzo.config.state.loadedTools:
                for toolId in pyzo.config.state.loadedTools:
                    pyzo.toolManager.loadTool(toolId)

            if g: g.pr('END PATCHED MainWindow._populate\n')
コード例 #4
0
    def _populate(self):
        '''
        This method is based on pyzo code
        Copyright (C) 2013-2018 by Almar Klein.
        '''

        trace = False and g.pyzo_trace_imports

        # Delayed imports, exactly as in MainWindow._populate.
        if trace:
            g.pr('\n===== MainWindowShim._populate\n')
        from pyzo.core.editorTabs import EditorTabs
        from pyzo.core.shellStack import ShellStackWidget
        from pyzo.core import codeparser
        from pyzo.core.history import CommandHistory
        from pyzo.tools import ToolManager
        if trace:
            g.pr('\n===== MainWindowShim._populate: end of delayed imports\n')
            g.pr('initial_draw:', self.initial_draw)
            g.pr('    use_menu:', self.use_menu)
            g.pr('   use_shell:', self.use_shell)
        #
        # Instantiate tool manager
        pyzo.toolManager = ToolManager()
        #
        # Instantiate and start source-code parser
        if pyzo.parser is None:
            pyzo.parser = codeparser.Parser()
            pyzo.parser.start()
        #
        # Create editor stack and make the central widget
        pyzo.editors = EditorTabs(self)
        self.setCentralWidget(pyzo.editors)
        #
        # Create floater for shell
        self._shellDock = dock = QtWidgets.QDockWidget(self)
        if pyzo.config.settings.allowFloatingShell:
            dock.setFeatures(dock.DockWidgetMovable | dock.DockWidgetFloatable)
        else:
            dock.setFeatures(dock.DockWidgetMovable)
        dock.setObjectName('shells')
        dock.setWindowTitle('Shells')
        self.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock)
        #
        # Create shell stack
        if self.use_shell:
            # Disabling the shell works.
            pyzo.shells = ShellStackWidget(self)
            dock.setWidget(pyzo.shells)
            pyzo.shells.menu = g.TracingNullObject(tag='pyzo.shells.menu')
            # To suppress menu events.
        else:
            pyzo.shells = g.TracingNullObject(tag='pyzo.shells')
        #
        # Initialize command history
        pyzo.command_history = CommandHistory('command_history.py')
        #
        # Create the default shell when returning to the event queue
        if self.use_shell:
            pyzo.core.main.callLater(pyzo.shells.addShell)
        #
        # Create statusbar
        if pyzo.config.view.showStatusbar:
            pyzo.status = self.statusBar()
        else:
            pyzo.status = None
            self.setStatusBar(None)
        #
        # Create the menu.
        if self.use_menu:
            from pyzo.core import menu
            pyzo.keyMapper = menu.KeyMapper()
            assert not isinstance(pyzo.keyMapper,
                                  (g.TracingNullObject, g.NullObject))
            # This should not be a Shim.
            menu.buildMenus(self.menuBar())
            pyzo.editors.addContextMenu()
            pyzo.shells.addContextMenu()
        else:
            # Shim:
            pyzo.shells = g.TracingNullObject(tag='pyzo.shells')
            pyzo.keyMapper = g.TracingNullObject(tag='pyzo.keyMapper')

            from pyzo.core.shellStack import ShellStackWidget

            def null_menu_callback(*args, **kwargs):
                pass  # g.trace(args, kwargs)

            # Apparently, doing nothing prevents the Shell from warming up.
            # For now, use_shell sets use_menu.
            assert not self.use_shell
            g.funcToMethod(null_menu_callback,
                           ShellStackWidget,
                           name='onShellStateChange')
            g.funcToMethod(null_menu_callback,
                           ShellStackWidget,
                           name='onShellDebugStateChange')
        #
        # Load tools
        if pyzo.config.state.newUser and not pyzo.config.state.loadedTools:
            pyzo.toolManager.loadTool('pyzosourcestructure')
            pyzo.toolManager.loadTool('pyzofilebrowser', 'pyzosourcestructure')
        elif pyzo.config.state.loadedTools:
            for toolId in pyzo.config.state.loadedTools:
                pyzo.toolManager.loadTool(toolId)
コード例 #5
0
ファイル: main.py プロジェクト: yltang52/pyzo
 def _populate(self):
     
     # Delayed imports
     from pyzo.core.editorTabs import EditorTabs
     from pyzo.core.shellStack import ShellStackWidget
     from pyzo.core import codeparser
     from pyzo.core.history import CommandHistory
     from pyzo.tools import ToolManager
     
     # Instantiate tool manager
     pyzo.toolManager = ToolManager()
     
     # Check to install conda now ...
     #from pyzo.util.bootstrapconda import check_for_conda_env
     #check_for_conda_env()
     
     # Instantiate and start source-code parser
     if pyzo.parser is None:
         pyzo.parser = codeparser.Parser()
         pyzo.parser.start()
     
     # Create editor stack and make the central widget
     pyzo.editors = EditorTabs(self)
     self.setCentralWidget(pyzo.editors)
     
     # Create floater for shell
     self._shellDock = dock = QtWidgets.QDockWidget(self)
     dock.setFeatures(dock.DockWidgetMovable)
     dock.setObjectName('shells')
     dock.setWindowTitle('Shells')
     self.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock)
     
     # Create shell stack
     pyzo.shells = ShellStackWidget(self)
     dock.setWidget(pyzo.shells)
     
     # Initialize command history
     pyzo.command_history = CommandHistory('command_history.py')
     
     # Create the default shell when returning to the event queue
     callLater(pyzo.shells.addShell)
     
     # Create statusbar
     if pyzo.config.view.showStatusbar:
         pyzo.status = self.statusBar()
     else:
         pyzo.status = None
         self.setStatusBar(None)
     
     # Create menu
     from pyzo.core import menu
     pyzo.keyMapper = menu.KeyMapper()
     menu.buildMenus(self.menuBar())
     
     # Add the context menu to the editor
     pyzo.editors.addContextMenu()
     pyzo.shells.addContextMenu()
     
     # Load tools
     if pyzo.config.state.newUser and not pyzo.config.state.loadedTools:
         pyzo.toolManager.loadTool('pyzosourcestructure')
         pyzo.toolManager.loadTool('pyzofilebrowser', 'pyzosourcestructure')
     elif pyzo.config.state.loadedTools: 
         for toolId in pyzo.config.state.loadedTools:
             pyzo.toolManager.loadTool(toolId)