eric6/CondaInterface/CondaNewEnvironmentDataDialog.py

Mon, 12 Oct 2020 19:28:42 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 12 Oct 2020 19:28:42 +0200
changeset 7781
607a6098cb44
parent 7780
41420f82c0ac
child 7923
91e843545d9a
permissions
-rw-r--r--

Performed some more code cleanup.

6731
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
3 # Copyright (c) 2019 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
6731
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to enter data for a new conda environment.
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from PyQt5.QtCore import pyqtSlot
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from E5Gui.E5PathPicker import E5PathPickerModes
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from .Ui_CondaNewEnvironmentDataDialog import Ui_CondaNewEnvironmentDataDialog
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 class CondaNewEnvironmentDataDialog(QDialog, Ui_CondaNewEnvironmentDataDialog):
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 Class implementing a dialog to enter data for a new conda environment.
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 def __init__(self, title, showRequirements, parent=None):
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 Constructor
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 @param title tirle of the dialog
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 @type str
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @param showRequirements flag indicating to show the requirements
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 file input widget
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @type bool
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @param parent reference to the parent widget
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @type QWidget
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 super(CondaNewEnvironmentDataDialog, self).__init__(parent)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 self.setupUi(self)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.setWindowTitle(title)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.__requirementsMode = showRequirements
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.requirementsFilePicker.setMode(E5PathPickerModes.OpenFileMode)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.requirementsFilePicker.setFilters(
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.tr("Text Files (*.txt);;All Files (*)"))
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.requirementsLabel.setVisible(showRequirements)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 self.requirementsFilePicker.setVisible(showRequirements)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.__updateOK()
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 msh = self.minimumSizeHint()
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.resize(max(self.width(), msh.width()), msh.height())
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 def __updateOK(self):
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 """
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 Private method to update the enabled state of the OK button.
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 """
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 enable = bool(self.nameEdit.text()) and bool(self.condaNameEdit.text())
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 if self.__requirementsMode:
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 enable &= bool(self.requirementsFilePicker.text())
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 @pyqtSlot(str)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 def on_nameEdit_textChanged(self, txt):
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 """
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 Private slot to handle changes of the logical name.
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 @param txt current text of the logical name entry
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 @type str
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 """
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 self.__updateOK()
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 @pyqtSlot(str)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 def on_condaNameEdit_textChanged(self, txt):
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 """
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 Private slot to handle changes of the conda name.
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 @param txt current text of the conda name entry
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 @type str
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 """
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.__updateOK()
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 @pyqtSlot(str)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 def on_requirementsFilePicker_textChanged(self, txt):
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 """
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 Private slot to handle changes of the requirements file name.
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 @param txt current text of the requirements file name entry
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 @type str
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 """
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 self.__updateOK()
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 def getData(self):
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 """
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 Public method to get the entered data.
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 @return tuple with the logical name of the new environment, the conda
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 name and the requirements file name
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 @rtype tuple of (str, str, str)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 """
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 if self.__requirementsMode:
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 requirementsFile = self.requirementsFilePicker.text()
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 else:
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 requirementsFile = ""
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 return (
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 self.nameEdit.text(),
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 self.condaNameEdit.text(),
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 requirementsFile
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 )

eric ide

mercurial