Carlos Pascual
2011-05-16 16:14:15 UTC
Hi,
I installed guidata on a SuSe11.1 (with PyQt 4.4) and I am getting the
following exception when running may of the tests:
+++++++++++++++++++
guidata/tests> python datasetgroup.py
Traceback (most recent call last):
File "datasetgroup.py", line 28, in <module>
g.edit()
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/datatypes.py", line 844, in edit
apply=apply)
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtwidgets.py", line 63, in __init__
self.setup_instance( instance )
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtwidgets.py", line 155, in setup_instance
self.edit_layout.append( self.layout_factory(dataset, grid) )
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtwidgets.py", line 107, in layout_factory
return DataSetEditLayout( self, instance, grid )
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtwidgets.py", line 189, in __init__
self.setup_layout( items )
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtwidgets.py", line 254, in setup_layout
widget = self.build_widget(item)
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtwidgets.py", line 261, in build_widget
widget = factory( item.bind(self.instance), self )
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtitemwidgets.py", line 794, in __init__
self.edit = EditLayoutClass(self.parent_layout.parent, self.dataset,
self.layout)
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtwidgets.py", line 189, in __init__
self.setup_layout( items )
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtwidgets.py", line 254, in setup_layout
widget = self.build_widget(item)
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtwidgets.py", line 261, in build_widget
widget = factory( item.bind(self.instance), self )
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtitemwidgets.py", line 517, in __init__
super(DirectoryWidget, self).__init__(item, parent_layout)
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtitemwidgets.py", line 418, in __init__
self.group.addWidget(old_group)
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtitemwidgets.py", line 406, in addWidget
super(GroupLayout, self).addWidget(widget)
AttributeError: 'super' object has no attribute 'addWidget'
+++++++++++++++++++++++++++
The problem is caused by the use of "super" outside of the __init__.py method
of subclasses that inherit from PyQt classes , which was problematic prior to
PyQt 4.5. See:
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/gotchas.html#super-
and-pyqt-classes
The solution is simple. For example, in *this case*, it is just a matter of
changing line 406 of qtitemwidgets.py from :
super(GroupLayout, self).addWidget(widget)
to:
QHBoxLayout.addWidget(self, widget)
(i.e., just using a explicit call to the parent class instead of using super,
which is in my opinion more readable anyway)
I haven't checked the rest of the package, but there will probably be other
uses of super that can be changed similarly with explicit calls to the parent
class . This would restore the compatibility with Qt 4.4 (which is what is
stated in the web page).
Note that the same problem occurs in guiqwt (see, for example
GridItem.attach() in curve.py )
Of course the lazy solution is just to make guidata and guiqwt depend on
Qt>=4.5. But for me that would be terrible because in my Institute we are
stuck to Qt 4.4 in production machines (we cannot change too often).
Cheers,
Carlos
--
+----------------------------------------------------+
Carlos Pascual Izarra
Scientific Software Coordinator
Computing Division
Cells / Alba Synchrotron [http:/www.cells.es]
Carretera BP 1413 de Cerdanyola-Sant Cugat, Km. 3.3
E-08290 Cerdanyola del Valles (Barcelona), Spain
E-mail: cpascual-***@public.gmane.org
Phone: +34 93 592 4428
+----------------------------------------------------+
I installed guidata on a SuSe11.1 (with PyQt 4.4) and I am getting the
following exception when running may of the tests:
+++++++++++++++++++
guidata/tests> python datasetgroup.py
Traceback (most recent call last):
File "datasetgroup.py", line 28, in <module>
g.edit()
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/datatypes.py", line 844, in edit
apply=apply)
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtwidgets.py", line 63, in __init__
self.setup_instance( instance )
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtwidgets.py", line 155, in setup_instance
self.edit_layout.append( self.layout_factory(dataset, grid) )
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtwidgets.py", line 107, in layout_factory
return DataSetEditLayout( self, instance, grid )
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtwidgets.py", line 189, in __init__
self.setup_layout( items )
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtwidgets.py", line 254, in setup_layout
widget = self.build_widget(item)
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtwidgets.py", line 261, in build_widget
widget = factory( item.bind(self.instance), self )
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtitemwidgets.py", line 794, in __init__
self.edit = EditLayoutClass(self.parent_layout.parent, self.dataset,
self.layout)
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtwidgets.py", line 189, in __init__
self.setup_layout( items )
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtwidgets.py", line 254, in setup_layout
widget = self.build_widget(item)
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtwidgets.py", line 261, in build_widget
widget = factory( item.bind(self.instance), self )
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtitemwidgets.py", line 517, in __init__
super(DirectoryWidget, self).__init__(item, parent_layout)
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtitemwidgets.py", line 418, in __init__
self.group.addWidget(old_group)
File "/usr/local/lib64/python2.6/site-
packages/guidata/dataset/qtitemwidgets.py", line 406, in addWidget
super(GroupLayout, self).addWidget(widget)
AttributeError: 'super' object has no attribute 'addWidget'
+++++++++++++++++++++++++++
The problem is caused by the use of "super" outside of the __init__.py method
of subclasses that inherit from PyQt classes , which was problematic prior to
PyQt 4.5. See:
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/gotchas.html#super-
and-pyqt-classes
The solution is simple. For example, in *this case*, it is just a matter of
changing line 406 of qtitemwidgets.py from :
super(GroupLayout, self).addWidget(widget)
to:
QHBoxLayout.addWidget(self, widget)
(i.e., just using a explicit call to the parent class instead of using super,
which is in my opinion more readable anyway)
I haven't checked the rest of the package, but there will probably be other
uses of super that can be changed similarly with explicit calls to the parent
class . This would restore the compatibility with Qt 4.4 (which is what is
stated in the web page).
Note that the same problem occurs in guiqwt (see, for example
GridItem.attach() in curve.py )
Of course the lazy solution is just to make guidata and guiqwt depend on
Qt>=4.5. But for me that would be terrible because in my Institute we are
stuck to Qt 4.4 in production machines (we cannot change too often).
Cheers,
Carlos
--
+----------------------------------------------------+
Carlos Pascual Izarra
Scientific Software Coordinator
Computing Division
Cells / Alba Synchrotron [http:/www.cells.es]
Carretera BP 1413 de Cerdanyola-Sant Cugat, Km. 3.3
E-08290 Cerdanyola del Valles (Barcelona), Spain
E-mail: cpascual-***@public.gmane.org
Phone: +34 93 592 4428
+----------------------------------------------------+