eric6/CondaInterface/CondaNewEnvironmentDataDialog.py

Sat, 31 Aug 2019 12:58:11 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 31 Aug 2019 12:58:11 +0200
branch
without_py2_and_pyqt4
changeset 7192
a22eee00b052
parent 6942
2602857055c5
child 7229
53054eb5b15a
permissions
-rw-r--r--

Started removing runtime support for Python2 and PyQt4.

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
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3 # Copyright (c) 2019 Detlev Offenbach <detlev@die-offenbachs.de>
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 __future__ import unicode_literals
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt5.QtCore import pyqtSlot
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
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 E5Gui.E5PathPicker import E5PathPickerModes
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 from .Ui_CondaNewEnvironmentDataDialog import Ui_CondaNewEnvironmentDataDialog
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
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 CondaNewEnvironmentDataDialog(QDialog, Ui_CondaNewEnvironmentDataDialog):
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 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
23 """
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 def __init__(self, title, showRequirements, parent=None):
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 Constructor
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @param title tirle of the dialog
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @type str
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @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
31 file input widget
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @type bool
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @param parent reference to the parent widget
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @type QWidget
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 """
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 super(CondaNewEnvironmentDataDialog, self).__init__(parent)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.setupUi(self)
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.setWindowTitle(title)
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.__requirementsMode = showRequirements
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.requirementsFilePicker.setMode(E5PathPickerModes.OpenFileMode)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.requirementsFilePicker.setFilters(
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.tr("Text Files (*.txt);;All Files (*)"))
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.requirementsLabel.setVisible(showRequirements)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.requirementsFilePicker.setVisible(showRequirements)
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 self.__updateOK()
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 msh = self.minimumSizeHint()
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 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
54
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 def __updateOK(self):
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 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
58 """
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 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
60 if self.__requirementsMode:
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 enable &= bool(self.requirementsFilePicker.text())
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 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 @pyqtSlot(str)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 def on_nameEdit_textChanged(self, txt):
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 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
69
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 @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
71 @type str
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 self.__updateOK()
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 @pyqtSlot(str)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 def on_condaNameEdit_textChanged(self, txt):
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 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
79
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 @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
81 @type str
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 self.__updateOK()
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 @pyqtSlot(str)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 def on_requirementsFilePicker_textChanged(self, txt):
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 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
89
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 @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
91 @type str
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 self.__updateOK()
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 def getData(self):
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 Public method to get the entered data.
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 @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
100 name and the requirements file name
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 @rtype tuple of (str, str, str)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 """
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 if self.__requirementsMode:
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 requirementsFile = self.requirementsFilePicker.text()
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 else:
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 requirementsFile = ""
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 return (
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 self.nameEdit.text(),
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 self.condaNameEdit.text(),
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 requirementsFile
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 )

eric ide

mercurial