eric6/VirtualEnv/VirtualenvAddEditDialog.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8043
0acf98cd089a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

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
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7911
diff changeset
3 # Copyright (c) 2018 - 2021 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 enter the data of a virtual environment.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
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 import os
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import sys
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
7911
4621c9082a43 Added support for PySide6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7910
diff changeset
13 from PyQt5.QtCore import pyqtSlot, Qt
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 from E5Gui.E5PathPicker import E5PathPickerModes
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 from .Ui_VirtualenvAddEditDialog import Ui_VirtualenvAddEditDialog
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 import Utilities
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 class VirtualenvAddEditDialog(QDialog, Ui_VirtualenvAddEditDialog):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 Class implementing a dialog to enter the data of a virtual environment.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 def __init__(self, manager, venvName="", venvDirectory="",
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
28 venvInterpreter="", isGlobal=False, isConda=False,
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
29 isRemote=False, execPath="", baseDir="", parent=None):
6338
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 venvName logical name of a virtual environment for editing
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 @type str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 @param venvDirectory directory of the virtual environment
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 @type str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 @param venvInterpreter Python interpreter of the virtual environment
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 @type str
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
41 @param isGlobal flag indicating a global environment
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
42 @type bool
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
43 @param isConda flag indicating an Anaconda virtual environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
44 @type bool
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
45 @param isRemote flag indicating a remotely accessed environment
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
46 @type bool
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
47 @param execPath search path string to be prepended to the PATH
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
48 environment variable
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
49 @type str
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
50 @param baseDir base directory for the virtual environments
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
51 @type str
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 @param parent reference to the parent widget
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 @type QWidget
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 super(VirtualenvAddEditDialog, self).__init__(parent)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.setupUi(self)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.__venvName = venvName
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 self.__manager = manager
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 self.__editMode = bool(venvName)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
62 if self.__editMode:
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
63 self.setWindowTitle(self.tr("Edit Virtual Environment"))
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
64 else:
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
65 self.setWindowTitle(self.tr("Add Virtual Environment"))
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
66
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
67 self.__envBaseDir = baseDir
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
68 if not self.__envBaseDir:
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
69 self.__envBaseDir = Utilities.getHomeDir()
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
70
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 self.targetDirectoryPicker.setMode(E5PathPickerModes.DirectoryMode)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 self.targetDirectoryPicker.setWindowTitle(
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 self.tr("Virtualenv Target Directory"))
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
74 self.targetDirectoryPicker.setDefaultDirectory(self.__envBaseDir)
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.pythonExecPicker.setMode(E5PathPickerModes.OpenFileMode)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 self.pythonExecPicker.setWindowTitle(
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 self.tr("Python Interpreter"))
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 self.pythonExecPicker.setDefaultDirectory(
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 sys.executable.replace("w.exe", ".exe"))
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
82 self.execPathEdit.setToolTip(self.tr(
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
83 "Enter the executable search path to be prepended to the PATH"
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
84 " environment variable. Use '{0}' as the separator.").format(
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
85 os.pathsep)
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
86 )
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
87
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.nameEdit.setText(venvName)
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
89 if venvName:
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
90 self.targetDirectoryPicker.setText(venvDirectory,
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
91 toNative=not isRemote)
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
92 else:
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
93 self.targetDirectoryPicker.setText(self.__envBaseDir,
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
94 toNative=not isRemote)
6719
705080ffd4a9 VirtualenvAddEditDialog: fixed an issue causing file path conversion for remote environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6716
diff changeset
95 self.pythonExecPicker.setText(venvInterpreter,
705080ffd4a9 VirtualenvAddEditDialog: fixed an issue causing file path conversion for remote environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6716
diff changeset
96 toNative=not isRemote)
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
97 self.globalCheckBox.setChecked(isGlobal)
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
98 self.anacondaCheckBox.setChecked(isConda)
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
99 self.remoteCheckBox.setChecked(isRemote)
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
100 self.execPathEdit.setText(execPath)
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 self.__updateOk()
7911
4621c9082a43 Added support for PySide6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7910
diff changeset
103
4621c9082a43 Added support for PySide6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7910
diff changeset
104 self.nameEdit.setFocus(Qt.OtherFocusReason)
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 def __updateOk(self):
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 Private slot to update the state of the OK button.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 if self.__editMode:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 enable = (
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 bool(self.nameEdit.text()) and
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 (self.nameEdit.text() == self.__venvName or
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 self.__manager.isUnique(self.nameEdit.text()))
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 )
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 else:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 enable = (
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 bool(self.nameEdit.text()) and
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 self.__manager.isUnique(self.nameEdit.text())
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 )
6341
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
121
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
122 if not self.globalCheckBox.isChecked():
7910
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
123 enable &= (
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
124 self.remoteCheckBox.isChecked() or (
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
125 bool(self.targetDirectoryPicker.text()) and
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
126 self.targetDirectoryPicker.text() != self.__envBaseDir and
2eeec6bc49e6 VirtualEnv Manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
127 os.path.exists(self.targetDirectoryPicker.text())
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
128 )
6341
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
129 )
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
130
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 enable = (
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 enable and
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
133 bool(self.pythonExecPicker.text()) and (
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
134 self.remoteCheckBox.isChecked() or
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
135 os.access(self.pythonExecPicker.text(), os.X_OK)
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
136 )
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 )
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 @pyqtSlot(str)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 def on_nameEdit_textChanged(self, txt):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 Private slot to handle changes of the logical name.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 @param txt current logical name
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 @type str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 self.__updateOk()
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 @pyqtSlot(str)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 def on_targetDirectoryPicker_textChanged(self, txt):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 Private slot to handle changes of the virtual environment directory.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 @param txt virtual environment directory
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 @type str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 self.__updateOk()
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 if txt:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 self.pythonExecPicker.setDefaultDirectory(txt)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 else:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 self.pythonExecPicker.setDefaultDirectory(
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 sys.executable.replace("w.exe", ".exe"))
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 @pyqtSlot(str)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 def on_pythonExecPicker_textChanged(self, txt):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 Private slot to handle changes of the virtual environment interpreter.
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 @param txt virtual environment interpreter
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 @type str
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 self.__updateOk()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176
6341
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
177 @pyqtSlot(bool)
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
178 def on_globalCheckBox_toggled(self, checked):
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
179 """
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
180 Private slot handling a change of the global check box state.
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
181
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
182 @param checked state of the check box
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
183 @type bool
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
184 """
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
185 self.__updateOk()
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
186
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
187 @pyqtSlot(bool)
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
188 def on_remoteCheckBox_toggled(self, checked):
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
189 """
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
190 Private slot handling a change of the remote check box state.
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
191
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
192 @param checked state of the check box
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
193 @type bool
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
194 """
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
195 self.__updateOk()
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
196
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
197 @pyqtSlot(bool)
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
198 def on_anacondaCheckBox_clicked(self, checked):
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
199 """
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
200 Private slot handling a user click on this check box.
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
201
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
202 @param checked state of the check box
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
203 @type bool
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
204 """
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
205 if checked and not bool(self.execPathEdit.text()):
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
206 # prepopulate the execPathEdit widget
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
207 if Utilities.isWindowsPlatform():
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
208 self.execPathEdit.setText(os.pathsep.join([
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
209 self.targetDirectoryPicker.text(),
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
210 os.path.join(self.targetDirectoryPicker.text(),
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
211 "Scripts"),
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
212 os.path.join(self.targetDirectoryPicker.text(),
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
213 "Library", "bin"),
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
214 ]))
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
215 else:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
216 self.execPathEdit.setText(
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
217 os.path.join(self.targetDirectoryPicker.text(),
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
218 "bin"),
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
219 )
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
220
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 def getData(self):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 Public method to retrieve the entered data.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
225 @return tuple containing the logical name, the directory, the
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
226 interpreter of the virtual environment, a flag indicating a
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
227 global environment, a flag indicating an Anaconda environment,
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
228 a flag indicating a remotely accessed environment and a string
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
229 to be prepended to the PATH environment variable
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
230 @rtype tuple of (str, str, str, bool, bool, bool, str)
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 """
6719
705080ffd4a9 VirtualenvAddEditDialog: fixed an issue causing file path conversion for remote environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6716
diff changeset
232 nativePaths = not self.remoteCheckBox.isChecked()
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
233 return (
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
234 self.nameEdit.text(),
6719
705080ffd4a9 VirtualenvAddEditDialog: fixed an issue causing file path conversion for remote environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6716
diff changeset
235 self.targetDirectoryPicker.text(toNative=nativePaths),
705080ffd4a9 VirtualenvAddEditDialog: fixed an issue causing file path conversion for remote environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6716
diff changeset
236 self.pythonExecPicker.text(toNative=nativePaths),
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
237 self.globalCheckBox.isChecked(),
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
238 self.anacondaCheckBox.isChecked(),
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
239 self.remoteCheckBox.isChecked(),
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
240 self.execPathEdit.text(),
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
241 )

eric ide

mercurial