Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1219

pyside2-uic - not create correct import statement for custom controls

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • 5.14.0
    • PySide
    • None
    • Windows

    Description

      Porting an older pyside code base to pyside2, having problem with way uic is handling the paths in custom components.

      I have a .ui file that I have promoted some generic 'widget' to specific type, and have specified the path to the widget code in Designer, it saves the following code snippit in the .ui file

      
       <customwidgets>
        <customwidget>
         <class&gt;MplWidget</class&gt;
         <extends>QWidget</extends>
         <header>UI.mplwidget</header>
         <container>1</container>
        </customwidget>
        <customwidget>
         <class&gt;SeqEditorControl</class&gt;
         <extends>QWidget</extends>
         <header>UI.scan.seqeditorcontrol</header>
         <container>1</container>
        </customwidget>
       </customwidgets>
       <resources/>
       <connections/>
      
      

      Then I run pyside2-uic on the ui file it generates the following import statements in the generated python code

      
      import MplWidget
      import SeqEditorControl
      
      

      This results in an error at run time because it does not know the module

        File "C:\prog\uvspy-pyside2\UI\scan\ui_scanwidget.py", line 18, in <module>
          import MplWidget
      ModuleNotFoundError: No module named 'MplWidget'
      

      where as with the older pyside-uic script it would generate

      
      from UI.mplwidget import MplWidget
      from UI.scan.seqeditorcontrol import SeqEditorControl
      
      

      Which would include the path that I had entered in the <header> field of the custom widget, and would correctly import the widgets.

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            steve_geo Stephen GEORGE
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes