Wed, 11 Nov 2020 20:03:21 +0100
Continued implementing the "Run Server" function.
# -*- coding: utf-8 -*- # Copyright (c) 2020 Detlev Offenbach <detlev@die-offenbachs.de> # """ Module implementing the Flask configuration page. """ from PyQt5.QtCore import pyqtSlot from E5Gui.E5Application import e5App from Preferences.ConfigurationPages.ConfigurationPageBase import ( ConfigurationPageBase ) from .Ui_FlaskPage import Ui_FlaskPage import UI.PixmapCache from .. import AnsiTools # TODO: add selection for the ANSI color scheme (see MicroPython) class FlaskPage(ConfigurationPageBase, Ui_FlaskPage): """ Class implementing the Flask configuration page. """ def __init__(self, plugin): """ Constructor @param plugin reference to the plugin object """ super(FlaskPage, self).__init__() self.setupUi(self) self.setObjectName("FlaskPage") self.colorSchemeComboBox.addItems( sorted(AnsiTools.getAvailableColorSchemes())) self.__plugin = plugin self.urlResetButton.setIcon( UI.PixmapCache.getIcon("editUndo")) self.py3VenvNamesReloadButton.setIcon( UI.PixmapCache.getIcon("reload")) venvManager = e5App().getObject("VirtualEnvManager") self.py3VenvNameComboBox.addItems( [""] + sorted(venvManager.getVirtualenvNames())) # set initial values self.externalBrowserCheckBox.setChecked( self.__plugin.getPreferences("UseExternalBrowser")) venvName = self.__plugin.getPreferences( "VirtualEnvironmentNamePy3") if venvName: index = self.py3VenvNameComboBox.findText(venvName) if index < 0: index = 0 self.py3VenvNameComboBox.setCurrentIndex(index) self.colorSchemeComboBox.setCurrentIndex( self.colorSchemeComboBox.findText( self.__plugin.getPreferences("AnsiColorScheme"))) self.urlEdit.setText( self.__plugin.getPreferences("FlaskDocUrl")) def save(self): """ Public slot to save the Flask configuration. """ self.__plugin.setPreferences( "UseExternalBrowser", self.externalBrowserCheckBox.isChecked()) self.__plugin.setPreferences( "VirtualEnvironmentNamePy3", self.py3VenvNameComboBox.currentText()) self.__plugin.setPreferences( "AnsiColorScheme", self.colorSchemeComboBox.currentText()) self.__plugin.setPreferences( "FlaskDocUrl", self.urlEdit.text()) @pyqtSlot() def on_py3VenvNamesReloadButton_clicked(self): """ Private slot to reload the virtual environment names. """ currentVenvName = self.py3VenvNameComboBox.currentText() self.py3VenvNameComboBox.clear() venvManager = e5App().getObject("VirtualEnvManager") self.py3VenvNameComboBox.addItems( [""] + sorted(venvManager.getVirtualenvNames())) if currentVenvName: index = self.py3VenvNameComboBox.findText(currentVenvName) if index < 0: index = 0 self.py3VenvNameComboBox.setCurrentIndex(index) @pyqtSlot() def on_urlResetButton_clicked(self): """ Private slot to reset the Flask documentation URL. """ self.urlEdit.setText( self.__plugin.getDefaultPreference("FlaskDocUrl"))