eric6/VirtualEnv/VirtualenvManagerDialog.py

Sun, 02 Feb 2020 11:04:32 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 02 Feb 2020 11:04:32 +0100
changeset 7380
c99320e859ca
parent 7360
9190402e4505
child 7635
0cdead130a81
permissions
-rw-r--r--

Fixed an issue related to showing the application name in the menu bar of Gnome desktop under Wayland.

6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7259
diff changeset
3 # Copyright (c) 2018 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to manage the list of defined virtual
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 environments.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt5.QtCore import pyqtSlot, Qt
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem, QHeaderView
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from .Ui_VirtualenvManagerDialog import Ui_VirtualenvManagerDialog
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 class VirtualenvManagerDialog(QDialog, Ui_VirtualenvManagerDialog):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 Class implementing a dialog to manage the list of defined virtual
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 environments.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
23 PythonVariantRole = Qt.UserRole
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
24 IsGlobalRole = Qt.UserRole + 1
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
25 IsCondaRole = Qt.UserRole + 2
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
26 IsRemoteRole = Qt.UserRole + 3
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
27 ExecPathRole = Qt.UserRole + 4
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
28
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 def __init__(self, manager, parent=None):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 Constructor
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @param manager reference to the virtual environment manager
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @type VirtualenvManager
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 @param parent reference to the parent widget
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 @type QWidget
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 super(VirtualenvManagerDialog, self).__init__(parent)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.setupUi(self)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.__manager = manager
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.__populateVenvList()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.__updateButtons()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 self.venvList.header().setSortIndicator(0, Qt.AscendingOrder)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 def __updateButtons(self):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 Private method to update the enabled state of the various buttons.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 selectedItemsCount = len(self.venvList.selectedItems())
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 topLevelItemCount = self.venvList.topLevelItemCount()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
55 deletableSelectedItemCount = 0
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
56 for itm in self.venvList.selectedItems():
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
57 if (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
58 itm.text(0) != "<default>" and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
59 bool(itm.text(1)) and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
60 not itm.data(0, VirtualenvManagerDialog.IsGlobalRole) and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
61 not itm.data(0, VirtualenvManagerDialog.IsRemoteRole)
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
62 ):
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
63 deletableSelectedItemCount += 1
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
64
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
65 deletableItemCount = 0
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
66 for index in range(topLevelItemCount):
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
67 itm = self.venvList.topLevelItem(index)
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
68 if (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
69 itm.text(0) != "<default>" and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
70 bool(itm.text(1)) and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
71 not itm.data(0, VirtualenvManagerDialog.IsRemoteRole)
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
72 ):
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
73 deletableItemCount += 1
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
74
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
75 canBeRemoved = (
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 selectedItemsCount == 1 and
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 self.venvList.selectedItems()[0].text(0) != "<default>"
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 )
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
79 canAllBeRemoved = (
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 topLevelItemCount == 1 and
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.venvList.topLevelItem(0).text(0) != "<default>"
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 )
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 self.editButton.setEnabled(selectedItemsCount == 1)
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
85
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
86 self.removeButton.setEnabled(selectedItemsCount > 1 or canBeRemoved)
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.removeAllButton.setEnabled(
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
88 topLevelItemCount > 1 or canAllBeRemoved)
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
89
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
90 self.deleteButton.setEnabled(deletableSelectedItemCount)
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
91 self.deleteAllButton.setEnabled(deletableItemCount)
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 @pyqtSlot()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 def on_addButton_clicked(self):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 Private slot to add a new entry.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 from .VirtualenvAddEditDialog import VirtualenvAddEditDialog
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 dlg = VirtualenvAddEditDialog(self.__manager)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 if dlg.exec_() == QDialog.Accepted:
6386
91dc4fa9bc9c Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6363
diff changeset
101 (venvName, venvDirectory, venvInterpreter, venvVariant,
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
102 isGlobal, isConda, isRemote, execPath) = dlg.getData()
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
104 self.__manager.addVirtualEnv(
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
105 venvName, venvDirectory, venvInterpreter, venvVariant,
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
106 isGlobal, isConda, isRemote, execPath)
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 @pyqtSlot()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 def on_newButton_clicked(self):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 Private slot to create a new virtual environment.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 self.__manager.createVirtualEnv()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 @pyqtSlot()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 def on_editButton_clicked(self):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 Private slot to edit the selected entry.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 selectedItem = self.venvList.selectedItems()[0]
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 oldVenvName = selectedItem.text(0)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 from .VirtualenvAddEditDialog import VirtualenvAddEditDialog
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
124 dlg = VirtualenvAddEditDialog(
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
125 self.__manager, selectedItem.text(0),
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
126 selectedItem.text(1), selectedItem.text(2),
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
127 selectedItem.data(0, VirtualenvManagerDialog.PythonVariantRole),
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
128 selectedItem.data(0, VirtualenvManagerDialog.IsGlobalRole),
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
129 selectedItem.data(0, VirtualenvManagerDialog.IsCondaRole),
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
130 selectedItem.data(0, VirtualenvManagerDialog.IsRemoteRole),
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
131 selectedItem.data(0, VirtualenvManagerDialog.ExecPathRole),
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
132 )
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 if dlg.exec_() == QDialog.Accepted:
6386
91dc4fa9bc9c Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6363
diff changeset
134 (venvName, venvDirectory, venvInterpreter, venvVariant,
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
135 isGlobal, isConda, isRemote, execPath) = dlg.getData()
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 if venvName != oldVenvName:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 self.__manager.renameVirtualEnv(
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
138 oldVenvName, venvName, venvDirectory, venvInterpreter,
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
139 venvVariant, isGlobal, isConda, isRemote, execPath)
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 else:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 self.__manager.setVirtualEnv(
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
142 venvName, venvDirectory, venvInterpreter, venvVariant,
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
143 isGlobal, isConda, isRemote, execPath)
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 @pyqtSlot()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 def on_removeButton_clicked(self):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 Private slot to remove all selected entries from the list but keep
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 their directories.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 selectedVenvs = []
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 for itm in self.venvList.selectedItems():
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 selectedVenvs.append(itm.text(0))
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 if selectedVenvs:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 self.__manager.removeVirtualEnvs(selectedVenvs)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 @pyqtSlot()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 def on_removeAllButton_clicked(self):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 Private slot to remove all entries from the list but keep their
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 directories.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 venvNames = []
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 for index in range(self.venvList.topLevelItemCount()):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 itm = self.venvList.topLevelItem(index)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 venvNames.append(itm.text(0))
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 if venvNames:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 self.__manager.removeVirtualEnvs(venvNames)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 @pyqtSlot()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 def on_deleteButton_clicked(self):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 Private slot to delete all selected entries from the list and disk.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 selectedVenvs = []
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 for itm in self.venvList.selectedItems():
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 selectedVenvs.append(itm.text(0))
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 if selectedVenvs:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 self.__manager.deleteVirtualEnvs(selectedVenvs)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 @pyqtSlot()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 def on_deleteAllButton_clicked(self):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 Private slot to delete all entries from the list and disk.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 venvNames = []
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 for index in range(self.venvList.topLevelItemCount()):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 itm = self.venvList.topLevelItem(index)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 venvNames.append(itm.text(0))
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 if venvNames:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 self.__manager.deleteVirtualEnvs(venvNames)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 @pyqtSlot()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 def on_venvList_itemSelectionChanged(self):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 Private slot handling a change of the selected items.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 self.__updateButtons()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 @pyqtSlot()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 def refresh(self):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 Public slot to refresh the list of shown items.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 # 1. remember selected entries
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 selectedVenvs = []
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 for itm in self.venvList.selectedItems():
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 selectedVenvs.append(itm.text(0))
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 # 2. clear the list
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 self.venvList.clear()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 # 3. re-populate the list
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 self.__populateVenvList()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 # 4. re-establish selection
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 for venvName in selectedVenvs:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 itms = self.venvList.findItems(venvName, Qt.MatchExactly, 0)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 if itms:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 itms[0].setSelected(True)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 def __populateVenvList(self):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 Private method to populate the list of virtual environments.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 environments = self.__manager.getEnvironmentEntries()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 for venvName in environments:
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
232 itm = QTreeWidgetItem(self.venvList, [
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 venvName,
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
234 environments[venvName]["path"],
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
235 environments[venvName]["interpreter"],
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 ])
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
237 itm.setData(0, VirtualenvManagerDialog.PythonVariantRole,
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
238 environments[venvName]["variant"])
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
239 itm.setData(0, VirtualenvManagerDialog.IsGlobalRole,
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
240 environments[venvName]["is_global"])
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
241 itm.setData(0, VirtualenvManagerDialog.IsCondaRole,
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
242 environments[venvName]["is_conda"])
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
243 itm.setData(0, VirtualenvManagerDialog.IsRemoteRole,
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
244 environments[venvName]["is_remote"])
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
245 itm.setData(0, VirtualenvManagerDialog.ExecPathRole,
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
246 environments[venvName]["exec_path"])
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
247
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
248 # show remote environments with underlined font
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
249 if environments[venvName]["is_remote"]:
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
250 font = itm.font(0)
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
251 font.setUnderline(True)
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
252 for column in range(itm.columnCount()):
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
253 itm.setFont(column, font)
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
254 else:
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
255 # local environments
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
256
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
257 # show global environments with bold font
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
258 if environments[venvName]["is_global"]:
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
259 font = itm.font(0)
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
260 font.setBold(True)
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
261 for column in range(itm.columnCount()):
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
262 itm.setFont(column, font)
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
263
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
264 # show Anaconda environments with italic font
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
265 if environments[venvName]["is_conda"]:
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
266 font = itm.font(0)
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
267 font.setItalic(True)
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
268 for column in range(itm.columnCount()):
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6680
diff changeset
269 itm.setFont(column, font)
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 self.__resizeSections()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 def __resizeSections(self):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 Private method to resize the sections of the environment list to their
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 contents.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 self.venvList.header().resizeSections(
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 QHeaderView.ResizeToContents)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 self.venvList.header().setStretchLastSection(True)

eric ide

mercurial