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