Tue, 28 Jun 2011 09:19:18 +0200
Added dialog support for PySide.
CodeTemplates/impl.py.tmpl | file | annotate | diff | comparison | revisions | |
CodeTemplates/impl_pyqt.py.tmpl | file | annotate | diff | comparison | revisions | |
CodeTemplates/impl_pyqt.py2.tmpl | file | annotate | diff | comparison | revisions | |
CodeTemplates/impl_pyside.py2.tmpl | file | annotate | diff | comparison | revisions | |
Project/CreateDialogCodeDialog.py | file | annotate | diff | comparison | revisions |
--- a/CodeTemplates/impl.py.tmpl Tue Jun 28 08:04:17 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -Module implementing $CLASSNAME$. -""" - -from PyQt4.QtCore import pyqtSlot -from PyQt4.QtGui import $SUPERCLASS$ - -from .Ui_$FORMFILE$ import Ui_$FORMCLASS$ - - -class $CLASSNAME$($SUPERCLASS$, Ui_$FORMCLASS$): - """ - Class documentation goes here. - """ - def __init__(self, parent=None): - """ - Constructor - - @param parent reference to the parent widget (QWidget) - """ - super().__init__(parent) - self.setupUi(self)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CodeTemplates/impl_pyqt.py.tmpl Tue Jun 28 09:19:18 2011 +0200 @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- + +""" +Module implementing $CLASSNAME$. +""" + +from PyQt4.QtCore import pyqtSlot +from PyQt4.QtGui import $SUPERCLASS$ + +from .Ui_$FORMFILE$ import Ui_$FORMCLASS$ + + +class $CLASSNAME$($SUPERCLASS$, Ui_$FORMCLASS$): + """ + Class documentation goes here. + """ + def __init__(self, parent=None): + """ + Constructor + + @param parent reference to the parent widget (QWidget) + """ + super().__init__(parent) + self.setupUi(self)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CodeTemplates/impl_pyqt.py2.tmpl Tue Jun 28 09:19:18 2011 +0200 @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- + +""" +Module implementing $CLASSNAME$. +""" + +from PyQt4.QtCore import pyqtSignature +from PyQt4.QtGui import $SUPERCLASS$ + +from .Ui_$FORMFILE$ import Ui_$FORMCLASS$ + + +class $CLASSNAME$($SUPERCLASS$, Ui_$FORMCLASS$): + """ + Class documentation goes here. + """ + def __init__(self, parent=None): + """ + Constructor + + @param parent reference to the parent widget (QWidget) + """ + $SUPERCLASS$.__init__(self, parent) + self.setupUi(self)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CodeTemplates/impl_pyside.py2.tmpl Tue Jun 28 09:19:18 2011 +0200 @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- + +""" +Module implementing $CLASSNAME$. +""" + +from PySide.QtCore import Slot +from PySide.QtGui import $SUPERCLASS$ + +from .Ui_$FORMFILE$ import Ui_$FORMCLASS$ + + +class $CLASSNAME$($SUPERCLASS$, Ui_$FORMCLASS$): + """ + Class documentation goes here. + """ + def __init__(self, parent=None): + """ + Constructor + + @param parent reference to the parent widget (QWidget) + """ + $SUPERCLASS$.__init__(self, parent) + self.setupUi(self)
--- a/Project/CreateDialogCodeDialog.py Tue Jun 28 08:04:17 2011 +0200 +++ b/Project/CreateDialogCodeDialog.py Tue Jun 28 09:19:18 2011 +0200 @@ -175,17 +175,19 @@ """ mapped = bytes(type_).decode() - # 1. check for const - mapped = mapped.replace("const ", "") - - # 2. check fpr * - mapped = mapped.replace("*", "") - - # 3. replace QString and QStringList - mapped = mapped.replace("QStringList", "list").replace("QString", "str") - - # 4. replace double by float - mapped = mapped.replace("double", "float") + if self.project.getProjectLanguage() != "Python2" or \ + self.project.getProjectType == "PySide": + # 1. check for const + mapped = mapped.replace("const ", "") + + # 2. check fpr * + mapped = mapped.replace("*", "") + + # 3. replace QString and QStringList + mapped = mapped.replace("QStringList", "list").replace("QString", "str") + + # 4. replace double by float + mapped = mapped.replace("double", "float") return mapped @@ -302,7 +304,16 @@ if self.__module is None: # new file try: - tmplName = os.path.join(getConfig('ericCodeTemplatesDir'), "impl.py.tmpl") + if self.project.getProjectLanguage() == "Python2": + if self.project.getProjectType() == "PySide": + tmplName = os.path.join(getConfig('ericCodeTemplatesDir'), + "impl_pyside.py2.tmpl") + else: + tmplName = os.path.join(getConfig('ericCodeTemplatesDir'), + "impl_pyqt.py2.tmpl") + else: + tmplName = os.path.join(getConfig('ericCodeTemplatesDir'), + "impl_pyqt.py.tmpl") tmplFile = open(tmplName, 'r', encoding="utf-8") template = tmplFile.read() tmplFile.close() @@ -366,6 +377,13 @@ break # do the coding stuff + if self.project.getProjectLanguage() == "Python2": + if self.project.getProjectType() == "PySide": + pyqtSignatureFormat = '@Slot({0})' + else: + pyqtSignatureFormat = '@pyqtSignature("{0}")' + else: + pyqtSignatureFormat = '@pyqtSlot({0})' for row in range(self.slotsModel.rowCount()): topItem = self.slotsModel.item(row) for childRow in range(topItem.rowCount()): @@ -373,8 +391,9 @@ if child.checkState() and \ child.flags() & Qt.ItemFlags(Qt.ItemIsUserCheckable): slotsCode.append('{0}\n'.format(indentStr)) - slotsCode.append('{0}@pyqtSlot({1})\n'.format( - indentStr, child.data(pyqtSignatureRole))) + slotsCode.append('{0}{1}\n'.format( + indentStr, + pyqtSignatureFormat.format(child.data(pyqtSignatureRole)))) slotsCode.append('{0}def {1}:\n'.format( indentStr, child.data(pythonSignatureRole))) slotsCode.append('{0}"""\n'.format(indentStr * 2))