eric7/VirtualEnv/VirtualenvManagerWidgets.py

branch
eric7
changeset 9144
135240382a3e
parent 8881
54e42bc2437a
child 9146
409d93549d61
equal deleted inserted replaced
9143:82f08c4fd930 9144:135240382a3e
5 5
6 """ 6 """
7 Module implementing a dialog to manage the list of defined virtual 7 Module implementing a dialog to manage the list of defined virtual
8 environments. 8 environments.
9 """ 9 """
10
11 import os
10 12
11 from PyQt6.QtCore import pyqtSlot, Qt 13 from PyQt6.QtCore import pyqtSlot, Qt
12 from PyQt6.QtWidgets import ( 14 from PyQt6.QtWidgets import (
13 QWidget, QDialog, QDialogButtonBox, QTreeWidgetItem, QHeaderView, 15 QWidget, QDialog, QDialogButtonBox, QTreeWidgetItem, QHeaderView,
14 QVBoxLayout 16 QVBoxLayout
21 23
22 import Utilities 24 import Utilities
23 import UI.PixmapCache 25 import UI.PixmapCache
24 26
25 27
28 # TODO: add a list refresh button
26 class VirtualenvManagerWidget(QWidget, Ui_VirtualenvManagerWidget): 29 class VirtualenvManagerWidget(QWidget, Ui_VirtualenvManagerWidget):
27 """ 30 """
28 Class implementing a widget to manage the list of defined virtual 31 Class implementing a widget to manage the list of defined virtual
29 environments. 32 environments.
30 """ 33 """
45 super().__init__(parent) 48 super().__init__(parent)
46 self.setupUi(self) 49 self.setupUi(self)
47 50
48 self.__manager = manager 51 self.__manager = manager
49 52
53 self.refreshButton.setIcon(UI.PixmapCache.getIcon("reload"))
50 self.addButton.setIcon(UI.PixmapCache.getIcon("plus")) 54 self.addButton.setIcon(UI.PixmapCache.getIcon("plus"))
51 self.newButton.setIcon(UI.PixmapCache.getIcon("new")) 55 self.newButton.setIcon(UI.PixmapCache.getIcon("new"))
52 self.editButton.setIcon(UI.PixmapCache.getIcon("edit")) 56 self.editButton.setIcon(UI.PixmapCache.getIcon("edit"))
57 self.upgradeButton.setIcon(UI.PixmapCache.getIcon("upgrade"))
53 self.removeButton.setIcon(UI.PixmapCache.getIcon("minus")) 58 self.removeButton.setIcon(UI.PixmapCache.getIcon("minus"))
54 self.removeAllButton.setIcon(UI.PixmapCache.getIcon("minus_3")) 59 self.removeAllButton.setIcon(UI.PixmapCache.getIcon("minus_3"))
55 self.deleteButton.setIcon(UI.PixmapCache.getIcon("fileDelete")) 60 self.deleteButton.setIcon(UI.PixmapCache.getIcon("fileDelete"))
56 self.deleteAllButton.setIcon(UI.PixmapCache.getIcon("fileDeleteList")) 61 self.deleteAllButton.setIcon(UI.PixmapCache.getIcon("fileDeleteList"))
57 self.saveButton.setIcon(UI.PixmapCache.getIcon("fileSave")) 62 self.saveButton.setIcon(UI.PixmapCache.getIcon("fileSave"))
114 self.removeAllButton.setEnabled( 119 self.removeAllButton.setEnabled(
115 topLevelItemCount > 1 or canAllBeRemoved) 120 topLevelItemCount > 1 or canAllBeRemoved)
116 121
117 self.deleteButton.setEnabled(deletableSelectedItemCount) 122 self.deleteButton.setEnabled(deletableSelectedItemCount)
118 self.deleteAllButton.setEnabled(deletableItemCount) 123 self.deleteAllButton.setEnabled(deletableItemCount)
124
125 if selectedItemsCount == 1:
126 venvName = self.venvList.selectedItems()[0].text(0)
127 venvDirectory = self.__manager.getVirtualenvDirectory(venvName)
128 self.upgradeButton.setEnabled(os.path.exists(os.path.join(
129 venvDirectory, "pyvenv.cfg")))
130 else:
131 self.upgradeButton.setEnabled(False)
132
133 @pyqtSlot()
134 def on_refreshButton_clicked(self):
135 """
136 Private slot to refresh the list of virtual environments.
137 """
138 self.__manager.reloadSettings()
139 self.__refresh()
119 140
120 @pyqtSlot() 141 @pyqtSlot()
121 def on_addButton_clicked(self): 142 def on_addButton_clicked(self):
122 """ 143 """
123 Private slot to add a new entry. 144 Private slot to add a new entry.
170 isGlobal, isConda, isRemote, execPath) 191 isGlobal, isConda, isRemote, execPath)
171 else: 192 else:
172 self.__manager.setVirtualEnv( 193 self.__manager.setVirtualEnv(
173 venvName, venvDirectory, venvInterpreter, isGlobal, 194 venvName, venvDirectory, venvInterpreter, isGlobal,
174 isConda, isRemote, execPath) 195 isConda, isRemote, execPath)
196
197 @pyqtSlot()
198 def on_upgradeButton_clicked(self):
199 """
200 Private slot to upgrade a virtual environment.
201 """
202 self.__manager.upgradeVirtualEnv(
203 self.venvList.selectedItems()[0].text(0))
175 204
176 @pyqtSlot() 205 @pyqtSlot()
177 def on_removeButton_clicked(self): 206 def on_removeButton_clicked(self):
178 """ 207 """
179 Private slot to remove all selected entries from the list but keep 208 Private slot to remove all selected entries from the list but keep

eric ide

mercurial