--- a/eric7/VirtualEnv/VirtualenvManagerWidgets.py Fri Jun 10 11:12:50 2022 +0200 +++ b/eric7/VirtualEnv/VirtualenvManagerWidgets.py Fri Jun 10 18:13:47 2022 +0200 @@ -8,6 +8,8 @@ environments. """ +import os + from PyQt6.QtCore import pyqtSlot, Qt from PyQt6.QtWidgets import ( QWidget, QDialog, QDialogButtonBox, QTreeWidgetItem, QHeaderView, @@ -23,6 +25,7 @@ import UI.PixmapCache +# TODO: add a list refresh button class VirtualenvManagerWidget(QWidget, Ui_VirtualenvManagerWidget): """ Class implementing a widget to manage the list of defined virtual @@ -47,9 +50,11 @@ self.__manager = manager + self.refreshButton.setIcon(UI.PixmapCache.getIcon("reload")) self.addButton.setIcon(UI.PixmapCache.getIcon("plus")) self.newButton.setIcon(UI.PixmapCache.getIcon("new")) self.editButton.setIcon(UI.PixmapCache.getIcon("edit")) + self.upgradeButton.setIcon(UI.PixmapCache.getIcon("upgrade")) self.removeButton.setIcon(UI.PixmapCache.getIcon("minus")) self.removeAllButton.setIcon(UI.PixmapCache.getIcon("minus_3")) self.deleteButton.setIcon(UI.PixmapCache.getIcon("fileDelete")) @@ -116,6 +121,22 @@ self.deleteButton.setEnabled(deletableSelectedItemCount) self.deleteAllButton.setEnabled(deletableItemCount) + + if selectedItemsCount == 1: + venvName = self.venvList.selectedItems()[0].text(0) + venvDirectory = self.__manager.getVirtualenvDirectory(venvName) + self.upgradeButton.setEnabled(os.path.exists(os.path.join( + venvDirectory, "pyvenv.cfg"))) + else: + self.upgradeButton.setEnabled(False) + + @pyqtSlot() + def on_refreshButton_clicked(self): + """ + Private slot to refresh the list of virtual environments. + """ + self.__manager.reloadSettings() + self.__refresh() @pyqtSlot() def on_addButton_clicked(self): @@ -174,6 +195,14 @@ isConda, isRemote, execPath) @pyqtSlot() + def on_upgradeButton_clicked(self): + """ + Private slot to upgrade a virtual environment. + """ + self.__manager.upgradeVirtualEnv( + self.venvList.selectedItems()[0].text(0)) + + @pyqtSlot() def on_removeButton_clicked(self): """ Private slot to remove all selected entries from the list but keep