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)
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)
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')
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)
def main_window_populate(self): """ Simulate MainWindow._populate(). This code, included commented-out code, is based on pyzo. Copyright (C) 2013-2019 by Almar Klein. """ # EKR:change: replaces self in most places. main_window = g.app.gui.main_window # print('\nBEGIN main_window_populate\n') # EKR:change-new imports from pyzo.core.main import callLater # 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() # EKR: Disabled in original. # 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 # EKR:change. Use None, not self. pyzo.editors = EditorTabs(None) # EKR:change. Create an Editors dock. self.make_global_dock('Editors', pyzo.editors) # self.setCentralWidget(pyzo.editors) # Create floater for shell # EKR:change: use a global *Leo* dock dock = g.app.gui.create_dock_widget( closeable=True, moveable=True, height=50, name='Shells', ) # Old code # 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') # EKR:change: Make the dock a *global* dock. main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock) # self.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock) # Create shell stack # EKR:change. Use None, not self. # A hack: patch _get_interpreters_win if 1: import pyzo.util.interpreters as interps interps._get_interpreters_win = _get_interpreters_win pyzo.shells = ShellStackWidget(None) 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) # EKR:change. pyzo.status = None # Create statusbar # if pyzo.config.view.showStatusbar: # pyzo.status = self.statusBar() # else: # pyzo.status = None # self.setStatusBar(None) from pyzo.core import menu pyzo.keyMapper = menu.KeyMapper() # EKR:change: Monkey-patch pyzo.keyMapper.setShortcut. g.funcToMethod(setShortcut, pyzo.keyMapper.__class__)