eric6/VirtualEnv/VirtualenvInterpreterSelectionDialog.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.

6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
c6af560e0039 VirtualEnv: started 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>
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to enter the interpreter for a virtual
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 environment.
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import os
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from PyQt5.QtCore import pyqtSlot
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 from E5Gui.E5PathPicker import E5PathPickerModes
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
19 from .Ui_VirtualenvInterpreterSelectionDialog import (
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 Ui_VirtualenvInterpreterSelectionDialog
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
21 )
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 class VirtualenvInterpreterSelectionDialog(
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 QDialog, Ui_VirtualenvInterpreterSelectionDialog):
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 Class implementing a dialog to enter the interpreter for a virtual
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 environment.
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 def __init__(self, venvName, venvDirectory, parent=None):
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 Constructor
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @param venvName name for the virtual environment
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 @type str
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 @param venvDirectory directory of the virtual environment
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 @type str
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 @param parent reference to the parent widget
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 @type QWidget
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 super(VirtualenvInterpreterSelectionDialog, self).__init__(parent)
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.setupUi(self)
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.pythonExecPicker.setMode(E5PathPickerModes.OpenFileMode)
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.pythonExecPicker.setWindowTitle(
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 self.tr("Python Interpreter"))
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.nameEdit.setText(venvName)
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.pythonExecPicker.setText(venvDirectory)
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 def __updateOK(self):
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 Private method to update the enabled status of the OK button.
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 interpreterPath = self.pythonExecPicker.text()
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 bool(interpreterPath) and
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 os.path.isfile(interpreterPath) and
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 os.access(interpreterPath, os.X_OK)
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 )
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 @pyqtSlot(str)
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 def on_pythonExecPicker_textChanged(self, txt):
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 Private slot to handle changes of the entered Python interpreter path.
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 @param txt entered Python interpreter path
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 @type str
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 self.__updateOK()
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 def getData(self):
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 Public method to get the entered data.
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
76 @return tuple containing the path of the selected Python interpreter
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
77 and the Python variant
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
78 @rtype tuple of (str, int)
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 """
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
80 return (
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
81 self.pythonExecPicker.text(),
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
82 3 - self.variantComboBox.currentIndex(),
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
83 )

eric ide

mercurial