PluginPipxInterface.py

changeset 2
26430067aa09
parent 1
d83409a59365
child 7
9a98f7260372
equal deleted inserted replaced
1:d83409a59365 2:26430067aa09
8 """ 8 """
9 9
10 import os 10 import os
11 import sysconfig 11 import sysconfig
12 12
13 from PyQt6.QtCore import QCoreApplication, QObject, QTranslator 13 from PyQt6.QtCore import QCoreApplication, QObject, Qt, QTranslator
14 from PyQt6.QtGui import QKeySequence
14 15
15 from eric7 import Preferences 16 from eric7 import Preferences
17 from eric7.EricGui import EricPixmapCache
18 from eric7.EricGui.EricAction import EricAction
16 from eric7.EricWidgets.EricApplication import ericApp 19 from eric7.EricWidgets.EricApplication import ericApp
17 from eric7.SystemUtilities import OSUtilities 20 from eric7.SystemUtilities import OSUtilities
21
22 try:
23 from eric7.UI.UserInterface import UserInterfaceSide
24
25 _Side = UserInterfaceSide.Right
26 except ImportError:
27 # backward compatibility for eric < 24.2
28 from eric7.UI.UserInterface import UserInterface
29
30 _Side = UserInterface.RightSide
18 31
19 # Start-Of-Header 32 # Start-Of-Header
20 __header__ = { 33 __header__ = {
21 "name": "pipx Interface", 34 "name": "pipx Interface",
22 "author": "Detlev Offenbach <detlev@die-offenbachs.de>", 35 "author": "Detlev Offenbach <detlev@die-offenbachs.de>",
54 67
55 data = { 68 data = {
56 "programEntry": True, 69 "programEntry": True,
57 "header": QCoreApplication.translate( 70 "header": QCoreApplication.translate(
58 "PluginPipxInterface", "PyPI Application Management" 71 "PluginPipxInterface", "PyPI Application Management"
59 ), 72 ),
60 "exe": pipx, 73 "exe": pipx,
61 "versionCommand": "--version", 74 "versionCommand": "--version",
62 "versionStartsWith": "", 75 "versionStartsWith": "",
63 "versionRe": None, 76 "versionRe": None,
64 "versionPosition": -1, 77 "versionPosition": -1,
151 Public method to activate this plug-in. 164 Public method to activate this plug-in.
152 165
153 @return tuple of None and activation status 166 @return tuple of None and activation status
154 @rtype bool 167 @rtype bool
155 """ 168 """
156 global error 169 global error, pipxInterfacePluginObject
157 error = "" # clear previous error 170 error = "" # clear previous error
171 pipxInterfacePluginObject = self
172
173 from PipxInterface.PipxWidget import PipxWidget
174
175 self.__widget = PipxWidget(self, fromEric=True)
176 iconName = "pipx96" if self.__ui.getLayoutType() == "Sidebars" else "pipx22"
177 self.__ui.addSideWidget(
178 _Side,
179 self.__widget,
180 EricPixmapCache.getIcon(os.path.join("PipxInterface", "icons", iconName)),
181 self.tr("PyPI Application Management"),
182 )
183
184 self.__activateAct = EricAction(
185 self.tr("PyPI Application Management"),
186 self.tr("PyPI Application Management"),
187 QKeySequence(self.tr("Ctrl+Alt+Shift+A")),
188 0,
189 self,
190 "pipx_interface_activate",
191 )
192 self.__activateAct.setStatusTip(
193 self.tr("Switch the input focus to the PyPI Application Management window.")
194 )
195 self.__activateAct.setWhatsThis(
196 self.tr(
197 """<b>Activate PyPI Application Management</b>"""
198 """<p>This switches the input focus to the PyPI Application"""
199 """ Management window.</p>"""
200 )
201 )
202 self.__activateAct.triggered.connect(self.__activateWidget)
203
204 self.__ui.addEricActions([self.__activateAct], "ui")
205 menu = self.__ui.getMenu("subwindow")
206 menu.addAction(self.__activateAct)
158 207
159 return None, True 208 return None, True
160 209
161 def deactivate(self): 210 def deactivate(self):
162 """ 211 """
163 Public method to deactivate this plug-in. 212 Public method to deactivate this plug-in.
164 """ 213 """
165 pass 214 menu = self.__ui.getMenu("subwindow")
215 menu.removeAction(self.__activateAct)
216 self.__ui.removeEricActions([self.__activateAct], "ui")
217 self.__ui.removeSideWidget(self.__widget)
218
219 self.__initialize()
166 220
167 def __loadTranslator(self): 221 def __loadTranslator(self):
168 """ 222 """
169 Private method to load the translation file. 223 Private method to load the translation file.
170 """ 224 """
185 "Warning: translation file '{0}' could not be" 239 "Warning: translation file '{0}' could not be"
186 " loaded.".format(translation) 240 " loaded.".format(translation)
187 ) 241 )
188 print("Using default.") 242 print("Using default.")
189 243
244 def __activateWidget(self):
245 """
246 Private slot to handle the activation of the MQTT Monitor.
247 """
248 uiLayoutType = self.__ui.getLayoutType()
249
250 if uiLayoutType == "Toolboxes":
251 self.__ui.rToolboxDock.show()
252 self.__ui.rToolbox.setCurrentWidget(self.__widget)
253 elif uiLayoutType == "Sidebars":
254 self.__ui.rightSidebar.show()
255 self.__ui.rightSidebar.setCurrentWidget(self.__widget)
256 else:
257 self.__widget.show()
258 self.__widget.setFocus(Qt.FocusReason.ActiveWindowFocusReason)
259
190 def getPreferences(self, key): 260 def getPreferences(self, key):
191 """ 261 """
192 Public method to retrieve the various settings values. 262 Public method to retrieve the various settings values.
193 263
194 @param key the key of the value to get 264 @param key the key of the value to get

eric ide

mercurial