--- a/ProjectDjango/ConfigurationPage/DjangoPage.py Fri Mar 30 14:47:18 2018 +0200 +++ b/ProjectDjango/ConfigurationPage/DjangoPage.py Sat Jun 23 16:35:46 2018 +0200 @@ -13,6 +13,7 @@ from E5Gui import E5FileDialog from E5Gui.E5Completers import E5DirCompleter, E5FileCompleter +from E5Gui.E5Application import e5App from Preferences.ConfigurationPages.ConfigurationPageBase import \ ConfigurationPageBase @@ -87,6 +88,26 @@ self.py3ShellCombo.addItem(self.tr("IPython"), "ipython") self.py3ShellCombo.addItem(self.tr("bpython"), "bpython") + try: + venvManager = e5App().getObject("VirtualEnvManager") + + self.py2VenvNameComboBox.addItems( + [""] + sorted(venvManager.getVirtualenvNamesForVariant(2))) + self.py3VenvNameComboBox.addItems( + [""] + sorted(venvManager.getVirtualenvNamesForVariant(3))) + + self.djangoVirtualEnvPy2Group.hide() + self.djangoVirtualEnvPy3Group.hide() + + self.__hasVirtualEnvironmentManager = True + except KeyError: + venvManager = None + + self.djangoVirtualEnvironmentPy2Group.hide() + self.djangoVirtualEnvironmentPy3Group.hide() + + self.__hasVirtualEnvironmentManager = False + # set initial values self.consoleCommandCombo.setEditText( self.__plugin.getPreferences("ConsoleCommand")) @@ -106,13 +127,31 @@ self.appsRecentSpinBox.setValue( self.__plugin.getPreferences("RecentNumberApps")) - self.virtualEnvPy2Edit.setText( - self.__plugin.getPreferences("VirtualEnvironmentPy2")) + if venvManager: + venvName = self.__plugin.getPreferences( + "VirtualEnvironmentNamePy2") + if venvName: + index = self.py2VenvNameComboBox.findText(venvName) + if index < 0: + index = 0 + self.py2VenvNameComboBox.setCurrentIndex(index) + else: + self.virtualEnvPy2Edit.setText( + self.__plugin.getPreferences("VirtualEnvironmentPy2")) self.py2ShellCombo.setCurrentIndex(self.py2ShellCombo.findData( self.__plugin.getPreferences("Python2ConsoleType"))) - self.virtualEnvPy3Edit.setText( - self.__plugin.getPreferences("VirtualEnvironmentPy3")) + if venvManager: + venvName = self.__plugin.getPreferences( + "VirtualEnvironmentNamePy3") + if venvName: + index = self.py3VenvNameComboBox.findText(venvName) + if index < 0: + index = 0 + self.py3VenvNameComboBox.setCurrentIndex(index) + else: + self.virtualEnvPy3Edit.setText( + self.__plugin.getPreferences("VirtualEnvironmentPy3")) self.py3ShellCombo.setCurrentIndex(self.py3ShellCombo.findData( self.__plugin.getPreferences("Python3ConsoleType"))) @@ -145,14 +184,24 @@ self.__plugin.setPreferences( "RecentNumberApps", self.appsRecentSpinBox.value()) - self.__plugin.setPreferences( - "VirtualEnvironmentPy2", self.virtualEnvPy2Edit.text()) + if self.__hasVirtualEnvironmentManager: + self.__plugin.setPreferences( + "VirtualEnvironmentNamePy2", + self.py2VenvNameComboBox.currentText()) + else: + self.__plugin.setPreferences( + "VirtualEnvironmentPy2", self.virtualEnvPy2Edit.text()) self.__plugin.setPreferences( "Python2ConsoleType", self.py2ShellCombo.itemData(self.py2ShellCombo.currentIndex())) - self.__plugin.setPreferences( - "VirtualEnvironmentPy3", self.virtualEnvPy3Edit.text()) + if self.__hasVirtualEnvironmentManager: + self.__plugin.setPreferences( + "VirtualEnvironmentNamePy3", + self.py3VenvNameComboBox.currentText()) + else: + self.__plugin.setPreferences( + "VirtualEnvironmentPy3", self.virtualEnvPy3Edit.text()) self.__plugin.setPreferences( "Python3ConsoleType", self.py3ShellCombo.itemData(self.py3ShellCombo.currentIndex()))