--- a/ProjectDjango/ConfigurationPage/DjangoPage.py Fri Dec 31 13:17:55 2021 +0100 +++ b/ProjectDjango/ConfigurationPage/DjangoPage.py Wed Sep 21 16:42:20 2022 +0200 @@ -10,9 +10,7 @@ from EricWidgets.EricApplication import ericApp from EricWidgets.EricPathPicker import EricPathPickerModes -from Preferences.ConfigurationPages.ConfigurationPageBase import ( - ConfigurationPageBase -) +from Preferences.ConfigurationPages.ConfigurationPageBase import ConfigurationPageBase from .Ui_DjangoPage import Ui_DjangoPage from Globals import isWindowsPlatform, isMacPlatform @@ -22,21 +20,22 @@ """ Class implementing the Django configuration page. """ + def __init__(self, plugin): """ Constructor - + @param plugin reference to the plugin object """ super().__init__() self.setupUi(self) self.setObjectName("DjangoPage") - + self.translationsPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) self.translationsPicker.setFilters(self.tr("All Files (*)")) - + self.__plugin = plugin - + consoleList = [] if isWindowsPlatform(): consoleList.append("cmd.exe /c") @@ -50,7 +49,7 @@ consoleList.append("mate-terminal -e") consoleList.append("xfce4-terminal -e") consoleList.append("xterm -e") - + consoleNoCloseList = [] if isWindowsPlatform(): consoleNoCloseList.append("cmd.exe /k") @@ -64,86 +63,92 @@ consoleNoCloseList.append("mate-terminal --profile=<noclose> -e") consoleNoCloseList.append("xfce4-terminal --hold -e") consoleNoCloseList.append("xterm -hold -e") - + self.consoleCommandCombo.addItems(consoleList) self.consoleCommandNoCloseCombo.addItems(consoleNoCloseList) - + self.py3ShellCombo.addItem(self.tr("Plain Python"), "python") self.py3ShellCombo.addItem(self.tr("IPython"), "ipython") self.py3ShellCombo.addItem(self.tr("bpython"), "bpython") - + venvManager = ericApp().getObject("VirtualEnvManager") - + self.py3VenvNameComboBox.addItems( - [""] + sorted(venvManager.getVirtualenvNames())) - + [""] + sorted(venvManager.getVirtualenvNames()) + ) + # set initial values self.consoleCommandCombo.setEditText( - self.__plugin.getPreferences("ConsoleCommand")) + self.__plugin.getPreferences("ConsoleCommand") + ) self.consoleCommandNoCloseCombo.setEditText( - self.__plugin.getPreferences("ConsoleCommandNoClose")) - - self.serverAddressEdit.setText( - self.__plugin.getPreferences("ServerAddress")) - self.ipv6CheckBox.setChecked( - self.__plugin.getPreferences("UseIPv6")) - self.threadingCheckBox.setChecked( - self.__plugin.getPreferences("UseThreading")) - + self.__plugin.getPreferences("ConsoleCommandNoClose") + ) + + self.serverAddressEdit.setText(self.__plugin.getPreferences("ServerAddress")) + self.ipv6CheckBox.setChecked(self.__plugin.getPreferences("UseIPv6")) + self.threadingCheckBox.setChecked(self.__plugin.getPreferences("UseThreading")) + self.externalBrowserCheckBox.setChecked( - self.__plugin.getPreferences("UseExternalBrowser")) - + self.__plugin.getPreferences("UseExternalBrowser") + ) + self.appsRecentSpinBox.setValue( - self.__plugin.getPreferences("RecentNumberApps")) - - venvName = self.__plugin.getPreferences( - "VirtualEnvironmentNamePy3") + self.__plugin.getPreferences("RecentNumberApps") + ) + + venvName = self.__plugin.getPreferences("VirtualEnvironmentNamePy3") if venvName: index = self.py3VenvNameComboBox.findText(venvName) if index < 0: index = 0 self.py3VenvNameComboBox.setCurrentIndex(index) - - self.py3ShellCombo.setCurrentIndex(self.py3ShellCombo.findData( - self.__plugin.getPreferences("Python3ConsoleType"))) - + + self.py3ShellCombo.setCurrentIndex( + self.py3ShellCombo.findData( + self.__plugin.getPreferences("Python3ConsoleType") + ) + ) + self.translationsPicker.setText( - self.__plugin.getPreferences("TranslationsEditor")) + self.__plugin.getPreferences("TranslationsEditor") + ) self.fuzzyTranslationsCheckBox.setChecked( - self.__plugin.getPreferences("FuzzyTranslations")) - + self.__plugin.getPreferences("FuzzyTranslations") + ) + def save(self): """ Public slot to save the Django configuration. """ self.__plugin.setPreferences( - "ConsoleCommand", - self.consoleCommandCombo.currentText()) - self.__plugin.setPreferences( - "ConsoleCommandNoClose", - self.consoleCommandNoCloseCombo.currentText()) - - self.__plugin.setPreferences( - "ServerAddress", self.serverAddressEdit.text()) - self.__plugin.setPreferences( - "UseIPv6", self.ipv6CheckBox.isChecked()) + "ConsoleCommand", self.consoleCommandCombo.currentText() + ) self.__plugin.setPreferences( - "UseThreading", self.threadingCheckBox.isChecked()) - - self.__plugin.setPreferences( - "UseExternalBrowser", self.externalBrowserCheckBox.isChecked()) - + "ConsoleCommandNoClose", self.consoleCommandNoCloseCombo.currentText() + ) + + self.__plugin.setPreferences("ServerAddress", self.serverAddressEdit.text()) + self.__plugin.setPreferences("UseIPv6", self.ipv6CheckBox.isChecked()) + self.__plugin.setPreferences("UseThreading", self.threadingCheckBox.isChecked()) + self.__plugin.setPreferences( - "RecentNumberApps", self.appsRecentSpinBox.value()) - + "UseExternalBrowser", self.externalBrowserCheckBox.isChecked() + ) + + self.__plugin.setPreferences("RecentNumberApps", self.appsRecentSpinBox.value()) + self.__plugin.setPreferences( - "VirtualEnvironmentNamePy3", - self.py3VenvNameComboBox.currentText()) + "VirtualEnvironmentNamePy3", self.py3VenvNameComboBox.currentText() + ) self.__plugin.setPreferences( "Python3ConsoleType", - self.py3ShellCombo.itemData(self.py3ShellCombo.currentIndex())) - + self.py3ShellCombo.itemData(self.py3ShellCombo.currentIndex()), + ) + self.__plugin.setPreferences( - "TranslationsEditor", self.translationsPicker.text()) + "TranslationsEditor", self.translationsPicker.text() + ) self.__plugin.setPreferences( - "FuzzyTranslations", self.fuzzyTranslationsCheckBox.isChecked()) + "FuzzyTranslations", self.fuzzyTranslationsCheckBox.isChecked() + )