Sun, 06 Jul 2014 14:23:25 +0200
Ported to PyQt5 and eric6.
# -*- coding: utf-8 -*- # Copyright (c) 2010 - 2014 Detlev Offenbach <detlev@die-offenbachs.de> # """ Module implementing a dialog to create getter and setter method names. """ from __future__ import unicode_literals from PyQt5.QtCore import pyqtSlot from PyQt5.QtWidgets import QDialog from Ui_GetterSetterDialog import Ui_GetterSetterDialog class GetterSetterDialog(QDialog, Ui_GetterSetterDialog): """ Class implementing a dialog to create getter and setter method names. """ def __init__(self, fieldName, parent=None): """ Constructor @param fieldName name of the field to create getter and setter method names (string) @param parent parent widget of the dialog (QWidget) """ QDialog.__init__(self, parent) self.setupUi(self) self.__fieldName = fieldName self.on_typeCheckBox_toggled(False) msh = self.minimumSizeHint() self.resize(max(self.width(), msh.width()), msh.height()) @pyqtSlot(bool) def on_typeCheckBox_toggled(self, checked): """ Private slot to react to changes of the type checkbox. @param checked state of the checkbox (boolean) """ if checked: self.getterEdit.setText("get_{0}".format(self.__fieldName)) self.setterEdit.setText("set_{0}".format(self.__fieldName)) else: self.getterEdit.setText( "get{0}{1}".format(self.__fieldName[0].upper(), self.__fieldName[1:])) self.setterEdit.setText( "set{0}{1}".format(self.__fieldName[0].upper(), self.__fieldName[1:])) def getData(self): """ Public method to return the getter and setter method names. @return tuple of two strings with getter and setter method names """ return (self.getterEdit.text(), self.setterEdit.text())