CondaInterface/CondaPackagesWidget.py

branch
conda
changeset 6705
8cf1c3851b5c
parent 6701
af29cf6ca309
child 6706
d792e054cde2
--- a/CondaInterface/CondaPackagesWidget.py	Wed Feb 06 19:35:51 2019 +0100
+++ b/CondaInterface/CondaPackagesWidget.py	Wed Feb 06 19:52:33 2019 +0100
@@ -55,9 +55,10 @@
         """
         Private method to get a list of environments and populate the selector.
         """
-        # TODO: populate with name and prefix
-        environmentNames = [""] + self.__conda.getCondaEnvironmentsList()
-        self.environmentsComboBox.addItems(sorted(environmentNames))
+        environments = [("", "")] + sorted(
+            self.__conda.getCondaEnvironmentsList())
+        for environment in environments:
+            self.environmentsComboBox.addItem(environment[0], environment[1])
     
     def __initCondaMenu(self):
         """
@@ -66,7 +67,8 @@
         """
         self.__condaMenu = QMenu(self)
         # TODO: implement Conda menu
-        self.__condaMenu.addAction(self.tr("Test Entry"), self.on_refreshButton_clicked)
+        self.__condaMenu.addAction(self.tr("Test Entry"),
+                                   self.on_refreshButton_clicked)
         
         self.condaMenuButton.setMenu(self.__condaMenu)
     
@@ -108,34 +110,40 @@
         self.upgradeAllButton.setEnabled(
             bool(self.__allUpdateableItems()))
     
-    # TODO: change to int = index
-    @pyqtSlot(str)
-    def on_environmentsComboBox_currentIndexChanged(self, name):
+    @pyqtSlot(int)
+    def on_environmentsComboBox_currentIndexChanged(self, index):
         """
         Private slot handling the selection of a conda environment.
         
-        @param name name of the selected conda environment name
-        @type str
+        @param index index of the selected conda environment
+        @type int
         """
         self.packagesList.clear()
-        if name:
+        prefix = self.environmentsComboBox.itemData(index)
+        if prefix:
             QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
             QApplication.processEvents()
             
+            self.packagesList.setUpdatesEnabled(False)
             # 1. populate with installed packages
-            # TODO: use prefix
-            installedPackages = self.__conda.getInstalledPackages(name=name)
-            for package, version, build_ in installedPackages:
-                QTreeWidgetItem(self.packagesList, [package, version])
+            installedPackages = \
+                self.__conda.getInstalledPackages(prefix=prefix)
+            for package, version, build in installedPackages:
+                itm = QTreeWidgetItem(self.packagesList, [package, version])
+                itm.setToolTip(1, self.tr("Build: {0}").format(build))
             
             # 2. update with update information
-            updateablePackages = self.__conda.getUpdateablePackages(name=name)
-            for package, version, build_ in updateablePackages:
+            updateablePackages = \
+                self.__conda.getUpdateablePackages(prefix=prefix)
+            for package, version, build in updateablePackages:
                 items = self.packagesList.findItems(
                     package, Qt.MatchExactly | Qt.MatchCaseSensitive)
                 if items:
                     items[0].setText(2, version)
+                    items[0].setToolTip(2, self.tr("Build: {0}").format(build))
             
+            self.packagesList.sortItems(0, Qt.AscendingOrder)
+            self.packagesList.setUpdatesEnabled(True)
             QApplication.restoreOverrideCursor()
         
         self.__updateActionButtons()

eric ide

mercurial