Project/NewPythonPackageDialog.py

Mon, 02 Apr 2018 12:04:18 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 02 Apr 2018 12:04:18 +0200
branch
maintenance
changeset 6206
a02b03b7bfec
parent 6048
82ad8ec9548c
child 6645
ad476851d7e0
permissions
-rw-r--r--

Merged with default branch to prepare new release.

# -*- coding: utf-8 -*-

# Copyright (c) 2007 - 2018 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing a dialog to add a new Python package.
"""

from __future__ import unicode_literals

from PyQt5.QtWidgets import QDialog, QDialogButtonBox
from PyQt5.QtCore import pyqtSlot

from .Ui_NewPythonPackageDialog import Ui_NewPythonPackageDialog


class NewPythonPackageDialog(QDialog, Ui_NewPythonPackageDialog):
    """
    Class implementing a dialog to add a new Python package.
    """
    def __init__(self, relPath, parent=None):
        """
        Constructor
        
        @param relPath initial package path relative to the project root
            (string)
        @param parent reference to the parent widget (QWidget)
        """
        super(NewPythonPackageDialog, self).__init__(parent)
        self.setupUi(self)
        
        self.okButton = self.buttonBox.button(QDialogButtonBox.Ok)
        self.okButton.setEnabled(False)
        
        rp = relPath.replace("/", ".").replace("\\", ".")
        self.packageEdit.setText(rp)
        
        msh = self.minimumSizeHint()
        self.resize(max(self.width(), msh.width()), msh.height())
    
    @pyqtSlot(str)
    def on_packageEdit_textChanged(self, txt):
        """
        Private slot called, when the package name is changed.
        
        @param txt new text of the package name edit (string)
        """
        self.okButton.setEnabled(txt != "")
    
    def getData(self):
        """
        Public method to retrieve the data entered into the dialog.
        
        @return package name (string)
        """
        return self.packageEdit.text()

eric ide

mercurial