[PyQt] pyqtProperty bug?
Emiliano Mennucci
ekumene at gmail.com
Thu Oct 23 10:08:52 BST 2008
I'm creating a widget for QtDesigner, using python and pyqt4. In order to
create a Qt property I wrote the following code:
[...]
def set_axis(self, axis):
print "DEBUG: set_axis"
self._axis = axis
def get_axis(self):
print "DEBUG: get_axis"
return self._axis
axisName = pyqtProperty("QString", get_axis, set_axis)
[...]
In the Designer, I can create the widget with no problem at all and I can
change the property value as well. I get both "DEBUG" prints. I save the
form as mydialg.ui.
The problem is on the main program, when I try to load the form. I use
uic.LoadUi("mydialog.ui") and get the following error:
Traceback (most recent call last):
File "main.py", line 8, in <module>
window = uic.loadUi("mydialog.ui")
File "/usr/lib/python2.5/site-packages/PyQt4/uic/__init__.py", line 106,
in loadUi
return loader.DynamicUILoader().loadUi(uifile, baseinstance)
File "/usr/lib/python2.5/site-packages/PyQt4/uic/Loader/loader.py", line
22, in loadUi
return self.parse(filename)
File "/usr/lib/python2.5/site-packages/PyQt4/uic/uiparser.py", line 572,
in parse
actor(elem)
File "/usr/lib/python2.5/site-packages/PyQt4/uic/uiparser.py", line 431,
in createUserInterface
self.traverseWidgetTree(elem)
File "/usr/lib/python2.5/site-packages/PyQt4/uic/uiparser.py", line 409,
in traverseWidgetTree
handler(self, child)
File "/usr/lib/python2.5/site-packages/PyQt4/uic/uiparser.py", line 155,
in createWidget
self.stack.push(self.setupObject(widgetClass(elem), parent, elem))
File "/usr/lib/python2.5/site-packages/PyQt4/uic/uiparser.py", line 131,
in setupObject
self.wprops.setProperties(obj, branch)
File "/usr/lib/python2.5/site-packages/PyQt4/uic/properties.py", line 293,
in setProperties
propname[1:]))(self.convert(prop, widget))
AttributeError: setAxisName
It seems that the loading form code is expecting the "set" method named in a
different way.
So I replaced my code with this one:
[...]
def setAxisName(self, axis):
print "DEBUG: set_axis"
self._axis = axis
def get_axis(self):
print "DEBUG: get_axis"
return self._axis
axisName = pyqtProperty("QString", get_axis, setAxisName)
[...]
And now it works perfectly (both on Designer and my program).
Is this a bug?
Emiliano
--
life's better without braces - Bruce Eckel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20081023/0b03c550/attachment.html
More information about the PyQt
mailing list