[PyQt] pyqtProperty bug?

Phil Thompson phil at riverbankcomputing.com
Fri Oct 24 19:04:16 BST 2008


On Thu, 23 Oct 2008 09:08:52 +0000, "Emiliano Mennucci" <ekumene at gmail.com>
wrote:
> 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?

Yes it is - should be fixed in tonight's snapshot.

Thanks,
Phil


More information about the PyQt mailing list