VirtualEnv/VirtualenvNameDialog.py

branch
conda
changeset 6677
6299d69a218a
child 6678
5f1de9e59227
equal deleted inserted replaced
6676:536ad4fa35aa 6677:6299d69a218a
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter the logical name for a new virtual
8 environment.
9 """
10
11 from PyQt5.QtCore import pyqtSlot, Qt
12 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
13
14 from .Ui_VirtualenvNameDialog import Ui_VirtualenvNameDialog
15
16
17 class VirtualenvNameDialog(QDialog, Ui_VirtualenvNameDialog):
18 """
19 Class implementing a dialog to enter the logical name for a new virtual
20 environment.
21 """
22 def __init__(self, environments, currentName, parent=None):
23 """
24 Constructor
25
26 @param environments list of environment names to be shown
27 @type list of str
28 @param currentName name to be shown in the name edit
29 @type str
30 @param parent reference to the parent widget
31 @type QWidget
32 """
33 super(VirtualenvNameDialog, self).__init__(parent)
34 self.setupUi(self)
35
36 self.envsList.addItems(environments)
37 self.nameEdit.setText(currentName)
38
39 self.nameEdit.setFocus(Qt.OtherFocusReason)
40 self.nameEdit.selectAll()
41
42 @pyqtSlot(str)
43 def on_nameEdit_textChanged(self, txt):
44 """
45 Slot documentation goes here.
46
47 @param txt contens of the name edit
48 @type str
49 """
50 items = self.envsList.findItems(txt, Qt.MatchExactly)
51 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(
52 bool(txt) and len(items) == 0)
53
54 def getName(self):
55 """
56 Public method to get the entered name.
57
58 @return name for the environment
59 @rtype str
60 """
61 return self.nameEdit.text()

eric ide

mercurial