--- a/Preferences/ConfigurationPages/DebuggerPython3Page.py Sat Jun 30 13:56:44 2018 +0200 +++ b/Preferences/ConfigurationPages/DebuggerPython3Page.py Sat Jun 30 13:59:56 2018 +0200 @@ -9,6 +9,8 @@ from __future__ import unicode_literals +from PyQt5.QtCore import pyqtSlot + from E5Gui.E5Application import e5App from E5Gui.E5PathPicker import E5PathPickerModes @@ -16,6 +18,7 @@ from .Ui_DebuggerPython3Page import Ui_DebuggerPython3Page import Preferences +import UI.PixmapCache class DebuggerPython3Page(ConfigurationPageBase, Ui_DebuggerPython3Page): @@ -31,25 +34,21 @@ self.setObjectName("DebuggerPython3Page") try: - virtualenvManager = e5App().getObject("VirtualEnvManager") + self.__virtualenvManager = e5App().getObject("VirtualEnvManager") except KeyError: from VirtualEnv.VirtualenvManager import VirtualenvManager - virtualenvManager = VirtualenvManager() - self.venvComboBox.addItems( - [""] + sorted(virtualenvManager.getVirtualenvNamesForVariant(3))) + self.__virtualenvManager = VirtualenvManager() + + self.venvDlgButton.setIcon(UI.PixmapCache.getIcon("virtualenv.png")) self.debugClientPicker.setMode(E5PathPickerModes.OpenFileMode) self.debugClientPicker.setToolTip(self.tr( "Press to select the Debug Client via a file selection dialog")) self.debugClientPicker.setFilters(self.tr("Python Files (*.py *.py3)")) + self.__populateAndSetVenvComboBox() + # set initial values - venvName = Preferences.getDebugger("Python3VirtualEnv") - if venvName: - index = self.venvComboBox.findText(venvName) - if index < 0: - index = 0 - self.venvComboBox.setCurrentIndex(index) dct = Preferences.getDebugger("DebugClientType3") if dct == "standard": self.standardButton.setChecked(True) @@ -63,7 +62,7 @@ Preferences.getDebugger("Python3NoEncoding")) self.sourceExtensionsEdit.setText( Preferences.getDebugger("Python3Extensions")) - + def save(self): """ Public slot to save the Debugger Python configuration. @@ -85,9 +84,42 @@ Preferences.setDebugger( "Python3NoEncoding", self.pyNoEncodingCheckBox.isChecked()) - Preferences.setDebugger( - "Python3Extensions", - self.sourceExtensionsEdit.text()) + + def __populateAndSetVenvComboBox(self): + """ + Private method to populate and set the virtual environment combo box. + """ + self.venvComboBox.clear() + self.venvComboBox.addItems( + [""] + + sorted(self.__virtualenvManager.getVirtualenvNamesForVariant(3)) + ) + + # set initial value + venvName = Preferences.getDebugger("Python3VirtualEnv") + if venvName: + index = self.venvComboBox.findText(venvName) + if index < 0: + index = 0 + self.venvComboBox.setCurrentIndex(index) + + @pyqtSlot() + def on_refreshButton_clicked(self): + """ + Private slot handling a click of the refresh button. + """ + self.sourceExtensionsEdit.setText( + Preferences.getDebugger("Python3Extensions")) + + @pyqtSlot() + def on_venvDlgButton_clicked(self): + """ + Slot documentation goes here. + """ + self.__virtualenvManager.showVirtualenvManagerDialog(modal=True) + self.__populateAndSetVenvComboBox() + self.activateWindow() + self.raise_() def create(dlg):