eric6/Project/NewPythonPackageDialog.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
child 7229
53054eb5b15a
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2007 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to add a new Python package.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
13 from PyQt5.QtCore import pyqtSlot
14
15 from .Ui_NewPythonPackageDialog import Ui_NewPythonPackageDialog
16
17
18 class NewPythonPackageDialog(QDialog, Ui_NewPythonPackageDialog):
19 """
20 Class implementing a dialog to add a new Python package.
21 """
22 def __init__(self, relPath, parent=None):
23 """
24 Constructor
25
26 @param relPath initial package path relative to the project root
27 (string)
28 @param parent reference to the parent widget (QWidget)
29 """
30 super(NewPythonPackageDialog, self).__init__(parent)
31 self.setupUi(self)
32
33 self.okButton = self.buttonBox.button(QDialogButtonBox.Ok)
34 self.okButton.setEnabled(False)
35
36 rp = relPath.replace("/", ".").replace("\\", ".")
37 self.packageEdit.setText(rp)
38
39 msh = self.minimumSizeHint()
40 self.resize(max(self.width(), msh.width()), msh.height())
41
42 @pyqtSlot(str)
43 def on_packageEdit_textChanged(self, txt):
44 """
45 Private slot called, when the package name is changed.
46
47 @param txt new text of the package name edit (string)
48 """
49 self.okButton.setEnabled(txt != "")
50
51 def getData(self):
52 """
53 Public method to retrieve the data entered into the dialog.
54
55 @return package name (string)
56 """
57 return self.packageEdit.text()

eric ide

mercurial