Re: [PyQt] pyqt5.1 baffling exceptions: AttributeError: 'Qxxxxxx' object has no attribute 'QWidget'
On Tue, 08 Oct 2013 10:29:44 +1100, Stephen Gava elgua...@gmail.com wrote: On 07/10/13 23:36, Phil Thompson wrote: Hopefully fixed in tonight's PyQt5 snapshot, or try the attached patch. great thanls Phil, i'll try building the snapshot when it's available and test that. any wild idea how far away a point release is so i can request an updated distro package? I'll do one at the end of this week. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] pyqt5.1 baffling exceptions: AttributeError: 'Qxxxxxx' object has no attribute 'QWidget'
This example runs without errors for me on Python2 in Linux. Greets Jens On Mon, Oct 7, 2013 at 2:27 AM, Stephen Gava elgua...@gmail.com wrote: Phil, i've attached a simple test case that illustrates this problem, here it is inline: import sys from PyQt5.QtWidgets import (QApplication,QMainWindow) class MainWindow(QMainWindow): def __init__(self): super(MainWindow,self).__init_**_() self.setWindowTitle('test case') top_level_window=self.window() print(top_level_window) gui_app=QApplication(sys.argv) gui_main_window=MainWindow() gui_main_window.show() sys.exit(gui_app.exec_()) the result of running the above is an exception: builtins.AttributeError: 'MainWindow' object has no attribute 'QWidget' with the traceback stopping in my code at the line where i try to use the result of self.window() (by simply printing it). if you comment out the print(top_level_window) the code runs fine so the error happens when trying to _use_ the result of self.window() in any way. obviously MainWindow is already a top level window, so in the more complex code where i'm getting these kind of errors the call to QWindow.window() is ocurring in widget (sub)classes that belong to the MainWindow. as i said this error crops up in several places, but seemingly after calls to either QWidget.window() or QWidget.childAt() in my code. i'm hoping you find some general cause for this, but if you need it i'll try to also come up with a simple case where it's triggered after the childAt() call. thanks, stephen. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] pyqt5.1 baffling exceptions: AttributeError: 'Qxxxxxx' object has no attribute 'QWidget'
On 07/10/13 19:07, Jens Persson wrote: This example runs without errors for me on Python2 in Linux. ok, i should say these errors are occurring with pyqt5,1, qt5.1 python 3.3 on 64bit linux. Greets Jens On Mon, Oct 7, 2013 at 2:27 AM, Stephen Gava elgua...@gmail.com mailto:elgua...@gmail.com wrote: Phil, i've attached a simple test case that illustrates this problem, here it is inline: import sys from PyQt5.QtWidgets import (QApplication,QMainWindow) class MainWindow(QMainWindow): def __init__(self): super(MainWindow,self).__init() self.setWindowTitle('test case') top_level_window=self.window() print(top_level_window) gui_app=QApplication(sys.argv) gui_main_window=MainWindow() gui_main_window.show() sys.exit(gui_app.exec_()) the result of running the above is an exception: builtins.AttributeError: 'MainWindow' object has no attribute 'QWidget' with the traceback stopping in my code at the line where i try to use the result of self.window() (by simply printing it). if you comment out the print(top_level_window) the code runs fine so the error happens when trying to _use_ the result of self.window() in any way. obviously MainWindow is already a top level window, so in the more complex code where i'm getting these kind of errors the call to QWindow.window() is ocurring in widget (sub)classes that belong to the MainWindow. as i said this error crops up in several places, but seemingly after calls to either QWidget.window() or QWidget.childAt() in my code. i'm hoping you find some general cause for this, but if you need it i'll try to also come up with a simple case where it's triggered after the childAt() call. thanks, stephen. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] pyqt5.1 baffling exceptions: AttributeError: 'Qxxxxxx' object has no attribute 'QWidget'
Le 07/10/2013 11:02, Jens Persson a écrit : For me, python-2.7.3, qt-5.1.1, pyqt-5.1 and 32-bit Linux. On Mon, Oct 7, 2013 at 10:13 AM, Stephen Gava elgua...@gmail.com mailto:elgua...@gmail.com wrote: On 07/10/13 19:07, Jens Persson wrote: This example runs without errors for me on Python2 in Linux. ok, i should say these errors are occurring with pyqt5,1, qt5.1 python 3.3 on 64bit linux. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt Works too with Python 3.2.3, Qt 5.0.2, PyQt 5.0, on 64bit Ubuntu -- Vincent V.V. Oqapy https://launchpad.net/oqapy . Qarte https://launchpad.net/qarte . PaQager https://launchpad.net/paqager ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] pyqt5.1 baffling exceptions: AttributeError: 'Qxxxxxx' object has no attribute 'QWidget'
On Mon, 07 Oct 2013 13:41:04 +0200, Vincent Vande Vyvre vincent.vandevy...@swing.be wrote: Le 07/10/2013 11:02, Jens Persson a écrit : For me, python-2.7.3, qt-5.1.1, pyqt-5.1 and 32-bit Linux. On Mon, Oct 7, 2013 at 10:13 AM, Stephen Gava elgua...@gmail.com mailto:elgua...@gmail.com wrote: On 07/10/13 19:07, Jens Persson wrote: This example runs without errors for me on Python2 in Linux. ok, i should say these errors are occurring with pyqt5,1, qt5.1 python 3.3 on 64bit linux. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt Works too with Python 3.2.3, Qt 5.0.2, PyQt 5.0, on 64bit Ubuntu It's Ok I can reproduce the problem. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] pyqt5.1 baffling exceptions: AttributeError: 'Qxxxxxx' object has no attribute 'QWidget'
On Mon, 07 Oct 2013 11:27:56 +1100, Stephen Gava elgua...@gmail.com wrote: Phil, i've attached a simple test case that illustrates this problem, here it is inline: import sys from PyQt5.QtWidgets import (QApplication,QMainWindow) class MainWindow(QMainWindow): def __init__(self): super(MainWindow,self).__init__() self.setWindowTitle('test case') top_level_window=self.window() print(top_level_window) gui_app=QApplication(sys.argv) gui_main_window=MainWindow() gui_main_window.show() sys.exit(gui_app.exec_()) the result of running the above is an exception: builtins.AttributeError: 'MainWindow' object has no attribute 'QWidget' with the traceback stopping in my code at the line where i try to use the result of self.window() (by simply printing it). if you comment out the print(top_level_window) the code runs fine so the error happens when trying to _use_ the result of self.window() in any way. obviously MainWindow is already a top level window, so in the more complex code where i'm getting these kind of errors the call to QWindow.window() is ocurring in widget (sub)classes that belong to the MainWindow. as i said this error crops up in several places, but seemingly after calls to either QWidget.window() or QWidget.childAt() in my code. i'm hoping you find some general cause for this, but if you need it i'll try to also come up with a simple case where it's triggered after the childAt() call. Hopefully fixed in tonight's PyQt5 snapshot, or try the attached patch. Thanks, Phildiff -r fc7b8711dba0 qpy/QtCore/qpycore_qobject_helpers.cpp --- a/qpy/QtCore/qpycore_qobject_helpers.cpp Sat Oct 05 16:44:56 2013 +0100 +++ b/qpy/QtCore/qpycore_qobject_helpers.cpp Mon Oct 07 13:33:22 2013 +0100 @@ -211,6 +211,7 @@ SIP_BLOCK_THREADS +PyTypeObject *base_pytype = sipTypeAsPyTypeObject(base); PyObject *mro = Py_TYPE(pySelf)-tp_mro; for (SIP_SSIZE_T i = 0; i PyTuple_GET_SIZE(mro); ++i) @@ -224,7 +225,10 @@ if (qstrcmp(pytype-tp_name, _clname) == 0) { -if (td == base) +// The generated type definitions represent the C++ (rather than +// Python) hierachy. If the C++ hierachy doesn't match then the +// super-type must be provided by a mixin. +if (PyType_IsSubtype(base_pytype, pytype)) *sipCpp = sipGetAddress(pySelf); else *sipCpp = sipGetMixinAddress(pySelf, td); ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] pyqt5.1 baffling exceptions: AttributeError: 'Qxxxxxx' object has no attribute 'QWidget'
On 07/10/13 22:58, Phil Thompson wrote: It's Ok I can reproduce the problem. ah great, even though there was another report of this, and i could reproduce it both with hand-built libraries and distribution packages, i was starting to fear it might one of those nutty 'specific to my environment' issues! ;) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] pyqt5.1 baffling exceptions: AttributeError: 'Qxxxxxx' object has no attribute 'QWidget'
On 07/10/13 23:36, Phil Thompson wrote: Hopefully fixed in tonight's PyQt5 snapshot, or try the attached patch. great thanls Phil, i'll try building the snapshot when it's available and test that. any wild idea how far away a point release is so i can request an updated distro package? all the best, stephen. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] pyqt5.1 baffling exceptions: AttributeError: 'Qxxxxxx' object has no attribute 'QWidget'
Phil, i've attached a simple test case that illustrates this problem, here it is inline: import sys from PyQt5.QtWidgets import (QApplication,QMainWindow) class MainWindow(QMainWindow): def __init__(self): super(MainWindow,self).__init__() self.setWindowTitle('test case') top_level_window=self.window() print(top_level_window) gui_app=QApplication(sys.argv) gui_main_window=MainWindow() gui_main_window.show() sys.exit(gui_app.exec_()) the result of running the above is an exception: builtins.AttributeError: 'MainWindow' object has no attribute 'QWidget' with the traceback stopping in my code at the line where i try to use the result of self.window() (by simply printing it). if you comment out the print(top_level_window) the code runs fine so the error happens when trying to _use_ the result of self.window() in any way. obviously MainWindow is already a top level window, so in the more complex code where i'm getting these kind of errors the call to QWindow.window() is ocurring in widget (sub)classes that belong to the MainWindow. as i said this error crops up in several places, but seemingly after calls to either QWidget.window() or QWidget.childAt() in my code. i'm hoping you find some general cause for this, but if you need it i'll try to also come up with a simple case where it's triggered after the childAt() call. thanks, stephen. On 05/10/13 18:19, Timothy W. Grove wrote: Hi Stephen, I don't really understand the issues here, but I also saw these kinds of errors cropping up recently when I moved an application from PyQt4 to PyQt5. I think I had at least three different cases of AttributeError: 'Qxx' object has no attribute 'QWidget'. One case I fixed by not giving a parent to the instance I was creating, simply, 'instance = SomeWidgetClass(self, parent=None)'; another I fixed by actually giving it a parent (!), and for the third case I just had to write different code to accomplish my task. Sorry this isn't very specific but maybe it will give you something to try. I'm hoping its just a bug in PyQt5 which will sort itself out somewhere down the line ... Best regards, Tim On 05/10/2013 07:02, Stephen Gava wrote: hi there, i posted an earlier question about one specific instance of this problem which seemed to relate to using QWidget.childAt() (no replies), but now i have the same puzzling issue cropping up in several places in a project i have moved from pyqt4 to pyqt5. under pyqt4 this code ran fine with none of these exceptions. under pyqt5 i'm getting exceptions of the kind detailed in the message title from time to time, ie exceptions where the final error message is: AttributeError: 'Qxx' object has no attribute 'QWidget' where Qxx is some kind of widget (in one instance QLabel, in another couple of cases QMainWindow). these errors seem like they might be comming from pyqt5 itself, as i don't reference QWidget as an attribute of any labels or mainwindows in my own code, however the tracebacks i get only follow the stack in my own code, in one instance this exception is thrown after a call to QWidget.childAt() and in some other instances after calls to QWidget.window() (which was Qwidget.topLevelWidget() in pyqt4). as i said the pyqt4 version never throws these exceptions, and i can't find anything in my code that should be causing this under pyqt5... does anyone have any advice on how i can at least try to work out where the issue is coming from? it's definitely caused by something new/different in ptqt5. thanks, stephen. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt import sys from PyQt5.QtWidgets import (QApplication,QMainWindow) class MainWindow(QMainWindow): def __init__(self): super(MainWindow,self).__init__() self.setWindowTitle('test case') top_level_window=self.window() print(top_level_window) gui_app=QApplication(sys.argv) gui_main_window=MainWindow() gui_main_window.show() sys.exit(gui_app.exec_()) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] pyqt5.1 baffling exceptions: AttributeError: 'Qxxxxxx' object has no attribute 'QWidget'
in case anyone searches this and needs workarounds for their code until the issue is resolved: in the case of this error being triggered by using the result of QWidget.window() i worked around the error in all cases by explicitly passing a reference to the parent toplevel window all the way down the line to where i needed to reference it, in the case of this error being triggered by using the result of QWidget.childAt() i had to implement separate logic to track and store a reference to the child widget the mouse cursor was over (which i did using mouse enter and leave events), in both cases of course being able to use the reference to the toplevel or child obtained dynamically from .window() or .childAt() would have been much much simpler, and i'll revert my workarounds once we have a pyqt5 fix for this. stephen. On 05/10/13 18:19, Timothy W. Grove wrote: Hi Stephen, I don't really understand the issues here, but I also saw these kinds of errors cropping up recently when I moved an application from PyQt4 to PyQt5. I think I had at least three different cases of AttributeError: 'Qxx' object has no attribute 'QWidget'. One case I fixed by not giving a parent to the instance I was creating, simply, 'instance = SomeWidgetClass(self, parent=None)'; another I fixed by actually giving it a parent (!), and for the third case I just had to write different code to accomplish my task. Sorry this isn't very specific but maybe it will give you something to try. I'm hoping its just a bug in PyQt5 which will sort itself out somewhere down the line ... Best regards, Tim On 05/10/2013 07:02, Stephen Gava wrote: hi there, i posted an earlier question about one specific instance of this problem which seemed to relate to using QWidget.childAt() (no replies), but now i have the same puzzling issue cropping up in several places in a project i have moved from pyqt4 to pyqt5. under pyqt4 this code ran fine with none of these exceptions. under pyqt5 i'm getting exceptions of the kind detailed in the message title from time to time, ie exceptions where the final error message is: AttributeError: 'Qxx' object has no attribute 'QWidget' where Qxx is some kind of widget (in one instance QLabel, in another couple of cases QMainWindow). these errors seem like they might be comming from pyqt5 itself, as i don't reference QWidget as an attribute of any labels or mainwindows in my own code, however the tracebacks i get only follow the stack in my own code, in one instance this exception is thrown after a call to QWidget.childAt() and in some other instances after calls to QWidget.window() (which was Qwidget.topLevelWidget() in pyqt4). as i said the pyqt4 version never throws these exceptions, and i can't find anything in my code that should be causing this under pyqt5... does anyone have any advice on how i can at least try to work out where the issue is coming from? it's definitely caused by something new/different in ptqt5. thanks, stephen. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] pyqt5.1 baffling exceptions: AttributeError: 'Qxxxxxx' object has no attribute 'QWidget'
hi there, i posted an earlier question about one specific instance of this problem which seemed to relate to using QWidget.childAt() (no replies), but now i have the same puzzling issue cropping up in several places in a project i have moved from pyqt4 to pyqt5. under pyqt4 this code ran fine with none of these exceptions. under pyqt5 i'm getting exceptions of the kind detailed in the message title from time to time, ie exceptions where the final error message is: AttributeError: 'Qxx' object has no attribute 'QWidget' where Qxx is some kind of widget (in one instance QLabel, in another couple of cases QMainWindow). these errors seem like they might be comming from pyqt5 itself, as i don't reference QWidget as an attribute of any labels or mainwindows in my own code, however the tracebacks i get only follow the stack in my own code, in one instance this exception is thrown after a call to QWidget.childAt() and in some other instances after calls to QWidget.window() (which was Qwidget.topLevelWidget() in pyqt4). as i said the pyqt4 version never throws these exceptions, and i can't find anything in my code that should be causing this under pyqt5... does anyone have any advice on how i can at least try to work out where the issue is coming from? it's definitely caused by something new/different in ptqt5. thanks, stephen. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] pyqt5.1 baffling exceptions: AttributeError: 'Qxxxxxx' object has no attribute 'QWidget'
Hi Stephen, I don't really understand the issues here, but I also saw these kinds of errors cropping up recently when I moved an application from PyQt4 to PyQt5. I think I had at least three different cases of AttributeError: 'Qxx' object has no attribute 'QWidget'. One case I fixed by not giving a parent to the instance I was creating, simply, 'instance = SomeWidgetClass(self, parent=None)'; another I fixed by actually giving it a parent (!), and for the third case I just had to write different code to accomplish my task. Sorry this isn't very specific but maybe it will give you something to try. I'm hoping its just a bug in PyQt5 which will sort itself out somewhere down the line ... Best regards, Tim On 05/10/2013 07:02, Stephen Gava wrote: hi there, i posted an earlier question about one specific instance of this problem which seemed to relate to using QWidget.childAt() (no replies), but now i have the same puzzling issue cropping up in several places in a project i have moved from pyqt4 to pyqt5. under pyqt4 this code ran fine with none of these exceptions. under pyqt5 i'm getting exceptions of the kind detailed in the message title from time to time, ie exceptions where the final error message is: AttributeError: 'Qxx' object has no attribute 'QWidget' where Qxx is some kind of widget (in one instance QLabel, in another couple of cases QMainWindow). these errors seem like they might be comming from pyqt5 itself, as i don't reference QWidget as an attribute of any labels or mainwindows in my own code, however the tracebacks i get only follow the stack in my own code, in one instance this exception is thrown after a call to QWidget.childAt() and in some other instances after calls to QWidget.window() (which was Qwidget.topLevelWidget() in pyqt4). as i said the pyqt4 version never throws these exceptions, and i can't find anything in my code that should be causing this under pyqt5... does anyone have any advice on how i can at least try to work out where the issue is coming from? it's definitely caused by something new/different in ptqt5. thanks, stephen. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] pyqt5.1 baffling exceptions: AttributeError: 'Qxxxxxx' object has no attribute 'QWidget'
On 05/10/13 18:19, Timothy W. Grove wrote: Hi Stephen, I don't really understand the issues here, but I also saw these kinds of errors cropping up recently when I moved an application from PyQt4 to PyQt5. I think I had at least three different cases of AttributeError: 'Qxx' object has no attribute 'QWidget'. One case I fixed by not giving a parent to the instance I was creating, simply, 'instance = SomeWidgetClass(self, parent=None)'; another I fixed by actually giving it a parent (!), and for the third case I just had to write different code to accomplish my task. Sorry this isn't very specific but maybe it will give you something to try. I'm hoping its just a bug in PyQt5 which will sort itself out somewhere down the line ... Best regards, Tim thanks Tim, at least for letting me know i'm not going mad here. ;) i'm going to see if i can put together a small test case that demonstarates the problem for Phil, but as you've noted here this seems to happen in a very unpredictable way so i'm not sure how i'll go. regards, stephen. On 05/10/2013 07:02, Stephen Gava wrote: hi there, i posted an earlier question about one specific instance of this problem which seemed to relate to using QWidget.childAt() (no replies), but now i have the same puzzling issue cropping up in several places in a project i have moved from pyqt4 to pyqt5. under pyqt4 this code ran fine with none of these exceptions. under pyqt5 i'm getting exceptions of the kind detailed in the message title from time to time, ie exceptions where the final error message is: AttributeError: 'Qxx' object has no attribute 'QWidget' where Qxx is some kind of widget (in one instance QLabel, in another couple of cases QMainWindow). these errors seem like they might be comming from pyqt5 itself, as i don't reference QWidget as an attribute of any labels or mainwindows in my own code, however the tracebacks i get only follow the stack in my own code, in one instance this exception is thrown after a call to QWidget.childAt() and in some other instances after calls to QWidget.window() (which was Qwidget.topLevelWidget() in pyqt4). as i said the pyqt4 version never throws these exceptions, and i can't find anything in my code that should be causing this under pyqt5... does anyone have any advice on how i can at least try to work out where the issue is coming from? it's definitely caused by something new/different in ptqt5. thanks, stephen. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt