UI/UserInterface.py

branch
maintenance
changeset 6395
613e37fabd96
parent 6319
df201b9fbad4
parent 6365
85f8745427a6
child 6455
22a6fc33ab6d
--- a/UI/UserInterface.py	Sat Jun 02 12:46:57 2018 +0200
+++ b/UI/UserInterface.py	Mon Jul 02 18:59:30 2018 +0200
@@ -238,6 +238,12 @@
         # load the view profiles
         self.profiles = Preferences.getUI("ViewProfiles2")
         
+        # Generate the virtual environment manager
+        from VirtualEnv.VirtualenvManager import VirtualenvManager
+        self.virtualenvManager = VirtualenvManager(self)
+        # register it early because it is needed very soon
+        e5App().registerObject("VirtualEnvManager", self.virtualenvManager)
+        
         # Generate the debug server object
         from Debugger.DebugServer import DebugServer
         debugServer = DebugServer()
@@ -2413,6 +2419,41 @@
         self.pluginRepoAct.triggered.connect(self.showPluginsAvailable)
         self.actions.append(self.pluginRepoAct)
         
+        self.virtualenvManagerAct = E5Action(
+            self.tr('Virtualenv Manager'),
+            UI.PixmapCache.getIcon("virtualenv.png"),
+            self.tr('&Virtualenv Manager...'),
+            0, 0, self,
+            'virtualenv_manager')
+        self.virtualenvManagerAct.setStatusTip(self.tr(
+            'Virtualenv Manager'))
+        self.virtualenvManagerAct.setWhatsThis(self.tr(
+            """<b>Virtualenv Manager</b>"""
+            """<p>This opens a dialog to manage the defined Python virtual"""
+            """ environments.</p>"""
+        ))
+        self.virtualenvManagerAct.triggered.connect(
+            self.virtualenvManager.showVirtualenvManagerDialog)
+        self.actions.append(self.virtualenvManagerAct)
+        
+        self.virtualenvConfigAct = E5Action(
+            self.tr('Virtualenv Configurator'),
+            UI.PixmapCache.getIcon("virtualenvConfig.png"),
+            self.tr('Virtualenv &Configurator...'),
+            0, 0, self,
+            'virtualenv_configurator')
+        self.virtualenvConfigAct.setStatusTip(self.tr(
+            'Virtualenv Configurator'))
+        self.virtualenvConfigAct.setWhatsThis(self.tr(
+            """<b>Virtualenv Configurator</b>"""
+            """<p>This opens a dialog for entering all the parameters"""
+            """ needed to create a Python virtual environment using"""
+            """ virtualenv or pyvenv.</p>"""
+        ))
+        self.virtualenvConfigAct.triggered.connect(
+            self.virtualenvManager.createVirtualEnv)
+        self.actions.append(self.virtualenvConfigAct)
+        
         # initialize viewmanager actions
         self.viewmanager.initActions()
         
@@ -2670,6 +2711,9 @@
         self.wizardsMenuAct.setEnabled(False)
         self.__menus["macros"] = self.viewmanager.initMacroMenu()
         self.__menus["extras"].addMenu(self.__menus["macros"])
+        self.__menus["extras"].addSeparator()
+        self.__menus["extras"].addAction(self.virtualenvManagerAct)
+        self.__menus["extras"].addAction(self.virtualenvConfigAct)
         self.toolGroupsMenu = QMenu(self.tr("Select Tool Group"), self)
         self.toolGroupsMenu.aboutToShow.connect(self.__showToolGroupsMenu)
         self.toolGroupsMenu.triggered.connect(self.__toolGroupSelected)
@@ -2869,6 +2913,9 @@
         toolstb.addAction(self.hexEditorAct)
         toolstb.addAction(self.iconEditorAct)
         toolstb.addAction(self.snapshotAct)
+        toolstb.addSeparator()
+        toolstb.addAction(self.virtualenvManagerAct)
+        toolstb.addAction(self.virtualenvConfigAct)
         if self.webBrowserAct:
             toolstb.addSeparator()
             toolstb.addAction(self.webBrowserAct)
@@ -3197,7 +3244,10 @@
         Private slot to handle the Versions dialog.
         """
         try:
-            import sip
+            try:
+                from PyQt5 import sip
+            except ImportError:
+                import sip
             sip_version_str = sip.SIP_VERSION_STR
         except (ImportError, AttributeError):
             sip_version_str = "sip version not available"
@@ -5038,9 +5088,15 @@
         pythonDocDir = Preferences.getHelp("PythonDocDir")
         if not pythonDocDir:
             if Utilities.isWindowsPlatform():
-                pythonDocDir = Utilities.getEnvironmentEntry(
-                    "PYTHON3DOCDIR",
-                    os.path.join(os.path.dirname(sys.executable), "doc"))
+                venvName = Preferences.getDebugger("Python3VirtualEnv")
+                interpreter = e5App().getObject("VirtualEnvManager")\
+                    .getVirtualenvInterpreter(venvName)
+                if interpreter:
+                    default = os.path.join(os.path.dirname(interpreter), "doc")
+                else:
+                    default = ""
+                pythonDocDir = \
+                    Utilities.getEnvironmentEntry("PYTHON3DOCDIR", default)
             else:
                 pythonDocDir = Utilities.getEnvironmentEntry(
                     "PYTHON3DOCDIR",
@@ -5101,11 +5157,13 @@
         Private slot to show the Python 2 documentation.
         """
         pythonDocDir = Preferences.getHelp("Python2DocDir")
-        executable = Preferences.getDebugger("PythonInterpreter")
         if not pythonDocDir:
             if Utilities.isWindowsPlatform():
-                if executable:
-                    default = os.path.join(os.path.dirname(executable), "doc")
+                venvName = Preferences.getDebugger("Python2VirtualEnv")
+                interpreter = e5App().getObject("VirtualEnvManager")\
+                    .getVirtualenvInterpreter(venvName)
+                if interpreter:
+                    default = os.path.join(os.path.dirname(interpreter), "doc")
                 else:
                     default = ""
                 pythonDocDir = \
@@ -6436,6 +6494,8 @@
         
         self.pluginManager.doShutdown()
         
+        self.virtualenvManager.shutdown()
+        
         if self.layoutType == "Sidebars":
             self.leftSidebar.shutdown()
             self.bottomSidebar.shutdown()

eric ide

mercurial