diff -r 7718e9b548fa -r f1bf1985434e CondaInterface/CondaPackagesWidget.py --- a/CondaInterface/CondaPackagesWidget.py Sat Feb 09 18:27:23 2019 +0100 +++ b/CondaInterface/CondaPackagesWidget.py Sat Feb 09 18:28:33 2019 +0100 @@ -94,10 +94,13 @@ """ self.__condaMenu = QMenu(self) # TODO: implement Conda menu - self.__condaMenu.addAction(self.tr("Test Entry"), - self.on_refreshButton_clicked) + self.__condaMenu.addAction( + self.tr("Update Conda"), self.__conda.updateConda) + self.__condaMenu.addSeparator() self.condaMenuButton.setMenu(self.__condaMenu) + + self.__condaMenu.aboutToShow.connect(self.__aboutToShowCondaMenu) def __selectedUpdateableItems(self): """ @@ -280,8 +283,11 @@ QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) QApplication.processEvents() - prefix = self.environmentsComboBox.itemData( - self.environmentsComboBox.currentIndex()) + if CondaInterface.condaVersion() >= (4, 4, 0): + prefix = "" + else: + prefix = self.environmentsComboBox.itemData( + self.environmentsComboBox.currentIndex()) ok, result = self.__conda.searchPackages( pattern, fullNameOnly=self.fullNameButton.isChecked(), @@ -336,7 +342,7 @@ if details: from .CondaPackageDetailsWidget import CondaPackageDetailsDialog dlg = CondaPackageDetailsDialog(details, self) - dlg.show() + dlg.exec_() @pyqtSlot(str) def on_searchEdit_textChanged(self, txt): @@ -366,10 +372,26 @@ @pyqtSlot() def on_installButton_clicked(self): """ - Slot documentation goes here. + Private slot to install a selected package. """ - # TODO: not implemented yet - raise NotImplementedError + if len(self.searchResultList.selectedItems()) == 1: + item = self.searchResultList.selectedItems()[0] + if item.parent() is None: + # it is just the package item + package = item.text(0) + else: + # item with version and build + package = "{0}={1}={2}".format( + item.parent().text(0), + item.text(1), + item.text(2), + ) + + prefix = self.environmentsComboBox.itemData( + self.environmentsComboBox.currentIndex()) + ok = self.__conda.installPackages([package], prefix=prefix) + if ok: + self.on_refreshButton_clicked() @pyqtSlot() def on_showDetailsButton_clicked(self): @@ -425,3 +447,10 @@ self.searchEdit.selectAll() self.__updateSearchActionButtons() + + @pyqtSlot() + def __aboutToShowCondaMenu(self): + """ + Private slot to handle the conda menu about to be shown. + """ + selectedEnvironment = self.environmentsComboBox.currentText()