ExtensionProtobuf/ConfigurationPage/ProtobufPage.py

Tue, 10 Dec 2024 15:48:53 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 10 Dec 2024 15:48:53 +0100
changeset 42
24ed3e1583dc
parent 40
c187d961ee3a
permissions
-rw-r--r--

Updated copyright for 2025.

1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
42
24ed3e1583dc Updated copyright for 2025.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 40
diff changeset
3 # Copyright (c) 2017 - 2025 Detlev Offenbach <detlev@die-offenbachs.de>
1
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the protobuf configuration page.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from PyQt6.QtCore import pyqtSlot
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from eric7.EricGui import EricPixmapCache
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from eric7.EricWidgets.EricApplication import ericApp
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from eric7.EricWidgets.EricPathPicker import EricPathPickerModes
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from eric7.Preferences.ConfigurationPages.ConfigurationPageBase import (
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 ConfigurationPageBase,
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 from .Ui_ProtobufPage import Ui_ProtobufPage
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 class ProtobufPage(ConfigurationPageBase, Ui_ProtobufPage):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 Class implementing the protobuf configuration page.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 def __init__(self, plugin):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 Constructor
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @param plugin reference to the plugin object
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @type ProtobufExtensionPlugin
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 super().__init__()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 self.setupUi(self)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.setObjectName("ProtobufPage")
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.__plugin = plugin
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 self.protocPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.protocPicker.setToolTip(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.tr(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 "Press to select the Protobuf compiler via a file selection dialog."
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.venvRefreshButton.setIcon(EricPixmapCache.getIcon("reload"))
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 # set initial values
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.protocPicker.setText(self.__plugin.getPreferences("protoc"))
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.__populateAndSetVenvComboBox()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 def save(self):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 Public slot to save the protobuf configuration.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 self.__plugin.setPreferences("protoc", self.protocPicker.text())
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.__plugin.setPreferences("grpcPythonEnv", self.venvComboBox.currentText())
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 def __populateAndSetVenvComboBox(self):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 Private method to populate and set the virtual environment combo box.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.venvComboBox.clear()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 self.venvComboBox.addItems(
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 [""] + sorted(ericApp().getObject("VirtualEnvManager").getVirtualenvNames())
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 )
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 # set initial value
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 venvName = self.__plugin.getPreferences("grpcPythonEnv")
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 self.venvComboBox.setCurrentText(venvName)
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 @pyqtSlot()
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 def on_venvRefreshButton_clicked(self):
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 Private slot to reload the list of virtual environments.
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 """
7157a39d4a0f First incarnation of the Protobuf and gRPC support plugin, that was an integral part of eric7 previously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 self.__populateAndSetVenvComboBox()

eric ide

mercurial