Tue, 13 Aug 2013 21:13:02 +0200
rope for Python2 projects enabled, if running on Python2
# -*- coding: utf-8 -*- # Copyright (c) 2010 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> # """ Module implementing a dialog to create getter and setter method names. """ from __future__ import unicode_literals # __IGNORE_WARNING__ from PyQt4.QtCore import pyqtSlot from PyQt4.QtGui 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) @pyqtSlot(bool) def on_typeCheckBox_toggled(self, checked): """ 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())