Sat, 31 Dec 2022 16:27:43 +0100
Updated copyright for 2023.
# -*- coding: utf-8 -*- # Copyright (c) 2017 - 2023 Detlev Offenbach <detlev@die-offenbachs.de> # """ Module implementing the protobuf configuration page. """ from PyQt6.QtCore import pyqtSlot from eric7.EricGui import EricPixmapCache from eric7.EricWidgets.EricApplication import ericApp from eric7.EricWidgets.EricPathPicker import EricPathPickerModes from eric7.Preferences.ConfigurationPages.ConfigurationPageBase import ( ConfigurationPageBase, ) from .Ui_ProtobufPage import Ui_ProtobufPage class ProtobufPage(ConfigurationPageBase, Ui_ProtobufPage): """ Class implementing the protobuf configuration page. """ def __init__(self, plugin): """ Constructor @param plugin reference to the plugin object @type ProtobufExtensionPlugin """ super().__init__() self.setupUi(self) self.setObjectName("ProtobufPage") self.__plugin = plugin self.protocPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) self.protocPicker.setToolTip( self.tr( "Press to select the Protobuf compiler via a file selection dialog." ) ) self.venvRefreshButton.setIcon(EricPixmapCache.getIcon("reload")) # set initial values self.protocPicker.setText(self.__plugin.getPreferences("protoc")) self.__populateAndSetVenvComboBox() def save(self): """ Public slot to save the protobuf configuration. """ self.__plugin.setPreferences("protoc", self.protocPicker.text()) self.__plugin.setPreferences("grpcPythonEnv", self.venvComboBox.currentText()) def __populateAndSetVenvComboBox(self): """ Private method to populate and set the virtual environment combo box. """ self.venvComboBox.clear() self.venvComboBox.addItems( [""] + sorted(ericApp().getObject("VirtualEnvManager").getVirtualenvNames()) ) # set initial value venvName = self.__plugin.getPreferences("grpcPythonEnv") self.venvComboBox.setCurrentText(venvName) @pyqtSlot() def on_venvRefreshButton_clicked(self): """ Private slot to reload the list of virtual environments. """ self.__populateAndSetVenvComboBox()