Menu

#151 Inheriting from UILoadable widget in another file fails

Jul15
resolved
None
bug
2015-03-30
2015-03-09
No

The following code will fail:

# file M1/Base.py
from taurus.external.qt import Qt
from taurus.qt.qtgui.util.ui import UILoadable

@UILoadable
class BaseWidget(Qt.QWidget):

    def __init__(self, parent=None):
        super(BaseWidget, self).__init__(parent)
        self.loadUi()
# file M2/MyWidget.py
from M1.Base import BaseWidget

@class MyWidget(BaseWidget):
    pass

app = Qt.QApplication([])
w = MyWidget()
w.show()
app.exec_()

A similar bug (bug-292) was found in the past and fixed for widgets in the same file. This bug report refers to two different classes defined in two different python files that reside in two different python packages.

1 Attachments

Discussion

  • Carlos Pascual

    Carlos Pascual - 2015-03-09

    Hi Tiago.

    I am trying to reproduce this bug (in order to integrate the patch) but I cannot. Could you please send a tar.gz with all the files and directories (including any needed ui files) so that it is reproduced?

     
  • Tiago Coutinho

    Tiago Coutinho - 2015-03-10
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,7 +1,7 @@
     The following  code will fail:
    
     ~~~~~~
    -# file Base.py
    +# file M1/Base.py
     from taurus.external.qt import Qt
     from taurus.qt.qtgui.util.ui import UILoadable
    
    @@ -14,7 +14,7 @@
     ~~~~~~
    
     ~~~~~~
    -# file mywidget.py
    +# file M2/MyWidget.py
     from Base import BaseWidget
    
     @class MyWidget(BaseWidget):
    @@ -26,6 +26,6 @@
     app.exec_()
     ~~~~~~
    
    -A similar bug ([bug-292][1]) was found in the past and fixed for widgets in the same file. This bug report refers to two different classes defined in two different python files.
    +A similar bug ([bug-292][1]) was found in the past and fixed for widgets in the same file. This bug report refers to two different classes defined in two different python files that reside in two different python packages.
    
     [1]: https://sourceforge.net/p/sardana/tickets/292/
    
     
  • Tiago Coutinho

    Tiago Coutinho - 2015-03-10

    Hi,

    I forgot to mention the files must reside in two different python packages. I edited the bug description to have this missing information.

    I added the tar.gz. To reproduce the problem:
    $ tar xzvf taurus-bug-339.tar.gz
    $ cd taurus-bug-339
    $ python test.py

     
  • Tiago Coutinho

    Tiago Coutinho - 2015-03-10
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -15,7 +15,7 @@
    
     ~~~~~~
     # file M2/MyWidget.py
    -from Base import BaseWidget
    +from M1.Base import BaseWidget
    
     @class MyWidget(BaseWidget):
         pass
    
     
  • Carlos Pascual

    Carlos Pascual - 2015-03-10
    • status: active --> resolved
     
  • Carlos Pascual

    Carlos Pascual - 2015-03-10

    Thanks, Tiago, that is what I suspected!
    Now I can reproduce it. I actually added a unittest to Taurus for this bug based on your example while integrating your patch.

    Thanks!

     
  • Tiago Coutinho

    Tiago Coutinho - 2015-03-30

    Ticket moved from /p/sardana/tickets/339/

    Can't be converted:

    • _category: taurus-qt
     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.