Esempio n. 1
0
 def open_file_browser(self):
     '''Open pyzo's file browser.'''
     try:
         #@+<< import the file browser >>
         #@+node:ekr.20190415051125.9: *4* << import the file browser >>
         #
         # Order is important!
         #
         # import pyzo # Done at the top level.
         import pyzo.core.main as main
         main.loadIcons()
         main.loadFonts()
         #
         from pyzo.core.menu import Menu
         from pyzo.tools.pyzoFileBrowser.tree import Tree
         if 0: print(Menu, Tree)  # Keep pyflakes happy.
         #
         from pyzo.tools.pyzoFileBrowser import PyzoFileBrowser
         #@-<< import the file browser >>
         self.monkey_patch_file_browser()
         w = PyzoFileBrowser(parent=None)
         w.show()
         self.widgets.append(w)
     except Exception:
         g.es_exception()
Esempio n. 2
0
 def open_shell_window(self, parent=None):
     '''Open pyzo's file browser.'''
     try:
         if not parent:
             # Create a "large enough" parent window.
             parent = QtWidgets.QFrame()
             parent.setMinimumSize(800, 500)
             # Avoids an error.
             self.widgets.append(parent)
         #@+<< import the shell >>
         #@+node:ekr.20190415182821.1: *4* << import the shell >>
         #
         # Standard prerequisites.
         import pyzo
         import pyzo.core.main as main
         main.loadIcons()
         main.loadFonts()
         from pyzo.core.menu import Menu
         from pyzo.tools.pyzoFileBrowser.tree import Tree
         if 0:  # To keep pyflakes quiet.
             print(pyzo, Menu, Tree)
         #
         # Build the keymapper
         from pyzo.core import menu
         pyzo.keyMapper = menu.KeyMapper()
         #
         # Shell-related...
         import pyzo.core.shellStack as shellStack
         import pyzo.core.shell as shell
         from pyzo.core import kernelbroker
         import pyzo.tools as tools
         from pyzo.core.shellStack import ShellStackWidget
         if 0:  # To keep pyflakes quiet.
             print(shellStack, shell, kernelbroker, tools)
         #@-<< import the shell >>
         ### self.monkey_patch_shell()
         shell_widget = ShellStackWidget(parent=parent)
         self.widgets.append(shell_widget)
         parent.show()
         # Must be done after creating the shell widget.
         return shell_widget
     except Exception:
         g.es_exception()
         return None
Esempio n. 3
0
    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()