eric7/CondaInterface/CondaPackagesWidget.py

branch
eric7
changeset 8356
68ec9c3d4de5
parent 8318
962bce857696
child 8358
144a6b854f70
equal deleted inserted replaced
8355:8a7677a63c8d 8356:68ec9c3d4de5
13 from PyQt6.QtWidgets import ( 13 from PyQt6.QtWidgets import (
14 QWidget, QToolButton, QMenu, QTreeWidgetItem, QApplication, QLineEdit, 14 QWidget, QToolButton, QMenu, QTreeWidgetItem, QApplication, QLineEdit,
15 QDialog 15 QDialog
16 ) 16 )
17 17
18 from E5Gui import E5FileDialog, E5MessageBox, E5TextInputDialog 18 from E5Gui import EricFileDialog, EricMessageBox, EricTextInputDialog
19 from E5Gui.E5Application import e5App 19 from E5Gui.EricApplication import ericApp
20 from E5Gui.E5OverrideCursor import E5OverrideCursor 20 from E5Gui.EricOverrideCursor import EricOverrideCursor
21 21
22 from .Ui_CondaPackagesWidget import Ui_CondaPackagesWidget 22 from .Ui_CondaPackagesWidget import Ui_CondaPackagesWidget
23 23
24 import UI.PixmapCache 24 import UI.PixmapCache
25 25
220 prefix = self.environmentsComboBox.itemData(index) 220 prefix = self.environmentsComboBox.itemData(index)
221 if prefix: 221 if prefix:
222 self.statusLabel.show() 222 self.statusLabel.show()
223 self.statusLabel.setText(self.tr("Getting installed packages...")) 223 self.statusLabel.setText(self.tr("Getting installed packages..."))
224 224
225 with E5OverrideCursor(): 225 with EricOverrideCursor():
226 # 1. populate with installed packages 226 # 1. populate with installed packages
227 self.packagesList.setUpdatesEnabled(False) 227 self.packagesList.setUpdatesEnabled(False)
228 installedPackages = self.__conda.getInstalledPackages( 228 installedPackages = self.__conda.getInstalledPackages(
229 prefix=prefix) 229 prefix=prefix)
230 for package, version, build in installedPackages: 230 for package, version, build in installedPackages:
285 """ 285 """
286 currentEnvironment = self.environmentsComboBox.currentText() 286 currentEnvironment = self.environmentsComboBox.currentText()
287 self.environmentsComboBox.clear() 287 self.environmentsComboBox.clear()
288 self.packagesList.clear() 288 self.packagesList.clear()
289 289
290 with E5OverrideCursor(): 290 with EricOverrideCursor():
291 self.__populateEnvironments() 291 self.__populateEnvironments()
292 292
293 index = self.environmentsComboBox.findText( 293 index = self.environmentsComboBox.findText(
294 currentEnvironment, 294 currentEnvironment,
295 Qt.MatchFlag.MatchExactly | Qt.MatchFlag.MatchCaseSensitive) 295 Qt.MatchFlag.MatchExactly | Qt.MatchFlag.MatchCaseSensitive)
354 Private method to search for packages. 354 Private method to search for packages.
355 """ 355 """
356 self.searchResultList.clear() 356 self.searchResultList.clear()
357 pattern = self.searchEdit.text() 357 pattern = self.searchEdit.text()
358 if pattern: 358 if pattern:
359 with E5OverrideCursor(): 359 with EricOverrideCursor():
360 prefix = ( 360 prefix = (
361 "" 361 ""
362 if CondaInterface.condaVersion() >= (4, 4, 0) else 362 if CondaInterface.condaVersion() >= (4, 4, 0) else
363 self.environmentsComboBox.itemData( 363 self.environmentsComboBox.itemData(
364 self.environmentsComboBox.currentIndex()) 364 self.environmentsComboBox.currentIndex())
398 if not ok: 398 if not ok:
399 try: 399 try:
400 message = result["message"] 400 message = result["message"]
401 except KeyError: 401 except KeyError:
402 message = result["error"] 402 message = result["error"]
403 E5MessageBox.warning( 403 EricMessageBox.warning(
404 self, 404 self,
405 self.tr("Conda Search Package Error"), 405 self.tr("Conda Search Package Error"),
406 message) 406 message)
407 407
408 def __showDetails(self, item): 408 def __showDetails(self, item):
556 Private slot to install packages. 556 Private slot to install packages.
557 """ 557 """
558 prefix = self.environmentsComboBox.itemData( 558 prefix = self.environmentsComboBox.itemData(
559 self.environmentsComboBox.currentIndex()) 559 self.environmentsComboBox.currentIndex())
560 if prefix: 560 if prefix:
561 ok, packageSpecs = E5TextInputDialog.getText( 561 ok, packageSpecs = EricTextInputDialog.getText(
562 self, 562 self,
563 self.tr("Install Packages"), 563 self.tr("Install Packages"),
564 self.tr("Package Specifications (separated by whitespace):"), 564 self.tr("Package Specifications (separated by whitespace):"),
565 QLineEdit.EchoMode.Normal, 565 QLineEdit.EchoMode.Normal,
566 minimumWidth=600) 566 minimumWidth=600)
576 Private slot to install packages from requirements files. 576 Private slot to install packages from requirements files.
577 """ 577 """
578 prefix = self.environmentsComboBox.itemData( 578 prefix = self.environmentsComboBox.itemData(
579 self.environmentsComboBox.currentIndex()) 579 self.environmentsComboBox.currentIndex())
580 if prefix: 580 if prefix:
581 requirements = E5FileDialog.getOpenFileNames( 581 requirements = EricFileDialog.getOpenFileNames(
582 self, 582 self,
583 self.tr("Install Packages"), 583 self.tr("Install Packages"),
584 "", 584 "",
585 self.tr("Text Files (*.txt);;All Files (*)")) 585 self.tr("Text Files (*.txt);;All Files (*)"))
586 if requirements: 586 if requirements:
631 prefix, 631 prefix,
632 ] 632 ]
633 ok, prefix, interpreter = self.__conda.createCondaEnvironment( 633 ok, prefix, interpreter = self.__conda.createCondaEnvironment(
634 args) 634 args)
635 if ok: 635 if ok:
636 e5App().getObject("VirtualEnvManager").addVirtualEnv( 636 ericApp().getObject("VirtualEnvManager").addVirtualEnv(
637 virtEnvName, prefix, interpreter, isConda=True) 637 virtEnvName, prefix, interpreter, isConda=True)
638 638
639 @pyqtSlot() 639 @pyqtSlot()
640 def __createEnvironment(self): 640 def __createEnvironment(self):
641 """ 641 """
654 "--file", 654 "--file",
655 requirements, 655 requirements,
656 ] 656 ]
657 ok, prefix, interpreter = self.__conda.createCondaEnvironment(args) 657 ok, prefix, interpreter = self.__conda.createCondaEnvironment(args)
658 if ok: 658 if ok:
659 e5App().getObject("VirtualEnvManager").addVirtualEnv( 659 ericApp().getObject("VirtualEnvManager").addVirtualEnv(
660 virtEnvName, prefix, interpreter, isConda=True) 660 virtEnvName, prefix, interpreter, isConda=True)
661 661
662 @pyqtSlot() 662 @pyqtSlot()
663 def __deleteEnvironment(self): 663 def __deleteEnvironment(self):
664 """ 664 """
665 Private slot to delete a conda environment. 665 Private slot to delete a conda environment.
666 """ 666 """
667 envName = self.environmentsComboBox.currentText() 667 envName = self.environmentsComboBox.currentText()
668 ok = E5MessageBox.yesNo( 668 ok = EricMessageBox.yesNo(
669 self, 669 self,
670 self.tr("Delete Environment"), 670 self.tr("Delete Environment"),
671 self.tr("""<p>Shall the environment <b>{0}</b> really be""" 671 self.tr("""<p>Shall the environment <b>{0}</b> really be"""
672 """ deleted?</p>""").format(envName) 672 """ deleted?</p>""").format(envName)
673 ) 673 )
688 if not os.path.exists(cfgFile): 688 if not os.path.exists(cfgFile):
689 self.__conda.writeDefaultConfiguration() 689 self.__conda.writeDefaultConfiguration()
690 690
691 # check, if the destination is writeable 691 # check, if the destination is writeable
692 if not os.access(cfgFile, os.W_OK): 692 if not os.access(cfgFile, os.W_OK):
693 E5MessageBox.critical( 693 EricMessageBox.critical(
694 None, 694 None,
695 self.tr("Edit Configuration"), 695 self.tr("Edit Configuration"),
696 self.tr("""The configuration file "{0}" does not exist""" 696 self.tr("""The configuration file "{0}" does not exist"""
697 """ or is not writable.""").format(cfgFile)) 697 """ or is not writable.""").format(cfgFile))
698 return 698 return
703 @pyqtSlot() 703 @pyqtSlot()
704 def __condaConfigure(self): 704 def __condaConfigure(self):
705 """ 705 """
706 Private slot to open the configuration page. 706 Private slot to open the configuration page.
707 """ 707 """
708 e5App().getObject("UserInterface").showPreferences("condaPage") 708 ericApp().getObject("UserInterface").showPreferences("condaPage")
709 709
710 @pyqtSlot() 710 @pyqtSlot()
711 def on_recheckButton_clicked(self): 711 def on_recheckButton_clicked(self):
712 """ 712 """
713 Private slot to re-check the availability of conda and adjust the 713 Private slot to re-check the availability of conda and adjust the

eric ide

mercurial