src/eric7/PipInterface/PipPackagesWidget.py

branch
eric7
changeset 10084
125166c6b66c
parent 10069
435cc5875135
child 10093
245505200513
equal deleted inserted replaced
10083:62019277dd0a 10084:125166c6b66c
175 """ 175 """
176 Constructor 176 Constructor
177 177
178 @param pip reference to the global pip interface 178 @param pip reference to the global pip interface
179 @type Pip 179 @type Pip
180 @param parent reference to the parent widget 180 @param parent reference to the parent widget (defaults to None)
181 @type QWidget 181 @type QWidget (optional)
182 """ 182 """
183 super().__init__(parent) 183 super().__init__(parent)
184 self.setupUi(self) 184 self.setupUi(self)
185 185
186 self.layout().setContentsMargins(0, 3, 0, 0) 186 self.layout().setContentsMargins(0, 3, 0, 0)
244 venvManager = ericApp().getObject("VirtualEnvManager") 244 venvManager = ericApp().getObject("VirtualEnvManager")
245 venvManager.virtualEnvironmentAdded.connect(self.on_refreshButton_clicked) 245 venvManager.virtualEnvironmentAdded.connect(self.on_refreshButton_clicked)
246 venvManager.virtualEnvironmentRemoved.connect(self.on_refreshButton_clicked) 246 venvManager.virtualEnvironmentRemoved.connect(self.on_refreshButton_clicked)
247 self.__selectedEnvironment = None 247 self.__selectedEnvironment = None
248 248
249 project = ericApp().getObject("Project") 249 with contextlib.suppress(KeyError):
250 project.projectOpened.connect(self.__projectOpened) 250 project = ericApp().getObject("Project")
251 project.projectClosed.connect(self.__projectClosed) 251 project.projectOpened.connect(self.__projectOpened)
252 project.projectClosed.connect(self.__projectClosed)
252 253
253 self.__initPipMenu() 254 self.__initPipMenu()
254 self.__populateEnvironments() 255 self.__populateEnvironments()
255 self.__updateActionButtons() 256 self.__updateActionButtons()
256 self.__updateDepActionButtons() 257 self.__updateDepActionButtons()
1552 1553
1553 def __pipConfigure(self): 1554 def __pipConfigure(self):
1554 """ 1555 """
1555 Private slot to open the configuration page. 1556 Private slot to open the configuration page.
1556 """ 1557 """
1557 ericApp().getObject("UserInterface").showPreferences("pipPage") 1558 try:
1559 ericApp().getObject("UserInterface").showPreferences("pipPage")
1560 except KeyError:
1561 # we were called from outside the eric IDE
1562 from eric7.Preferences.ConfigurationDialog import ( # noqa: I101
1563 ConfigurationDialog,
1564 ConfigurationMode,
1565 )
1566
1567 dlg = ConfigurationDialog(
1568 None,
1569 "Configuration",
1570 True,
1571 fromEric=False,
1572 displayMode=ConfigurationMode.PIPMANAGERMODE,
1573 )
1574 dlg.show()
1575 dlg.showConfigurationPageByName("pipPage")
1576 dlg.exec()
1577 if dlg.result() == QDialog.DialogCode.Accepted:
1578 dlg.setPreferences()
1579 Preferences.syncPreferences()
1558 1580
1559 @pyqtSlot() 1581 @pyqtSlot()
1560 def __showCacheInfo(self): 1582 def __showCacheInfo(self):
1561 """ 1583 """
1562 Private slot to show information about the cache. 1584 Private slot to show information about the cache.

eric ide

mercurial