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

Generating .py from .ui: Code for QFrame is generated with Syntax Error

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • 6.8.0.2
    • Build System, PySide
    • None
    • Python 3.11.9
      Windows 10.0.19045 Build 19045 64Bit
    • Windows

    Description

      If you create a QFrame: 

      and then create the .py from .ui with:
      ".venv\Scripts\pyside6-uic.exe"
      or 
      directly use the QtDesigner to generate the code:

      You will get:

      // Code-Platzhalter  File "C:\Program Files\Python311\Lib\runpy.py", line 198, in _run_module_as_main
          return _run_code(code, main_globals, None,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Program Files\Python311\Lib\runpy.py", line 88, in _run_code
          exec(code, run_globals)
        File "c:\Users\KUDA\.vscode\extensions\ms-python.debugpy-2024.13.2024103001-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy\__main__.py", line 71, in <module>
          cli.main()
        File "c:\Users\KUDA\.vscode\extensions\ms-python.debugpy-2024.13.2024103001-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 501, in main
          run()
        File "c:\Users\KUDA\.vscode\extensions\ms-python.debugpy-2024.13.2024103001-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 351, in run_file
          runpy.run_path(target, run_name="__main__")
        File "c:\Users\KUDA\.vscode\extensions\ms-python.debugpy-2024.13.2024103001-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 309, in run_path
          code, fname = _get_code_from_file(run_name, path_name)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "c:\Users\KUDA\.vscode\extensions\ms-python.debugpy-2024.13.2024103001-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 283, in _get_code_from_file
          code = compile(f.read(), fname, "exec")
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "c:\src\gpe-eqepygui\Modules\Gui\pyFile\ui_EqeLeicaGui.py", line 95
          self.LeftPanel.addWidget(self.LeftLogoFrame, 0, |Qt.AlignmentFlag.AlignVCenter)
                                                          ^
      SyntaxError: invalid syntax 
      Snippet from .py File:
      
      
       self.LeftPanel = QVBoxLayout(self.LeftContentFrame)        self.LeftPanel.setSpacing(0)        self.LeftPanel.setObjectName(u"LeftPanel")        self.LeftPanel.setContentsMargins(0, 0, 0, 0)        self.LeftLogoFrame = QFrame(self.LeftContentFrame)        self.LeftLogoFrame.setObjectName(u"LeftLogoFrame")        self.LeftLogoFrame.setStyleSheet(u"background-color: transparent; /* Transparenter Hintergrund */\n""border: 0px; /* Kein Rand */")        self.LeftLogoFrame.setLineWidth(0)        self.LeftLogo = QVBoxLayout(self.LeftLogoFrame)        self.LeftLogo.setSpacing(0)        self.LeftLogo.setObjectName(u"LeftLogo")        self.LeftLogo.setContentsMargins(0, 0, 0, 0)        self.CompanyLogo = QLabel(self.LeftLogoFrame)        self.CompanyLogo.setObjectName(u"CompanyLogo")        sizePolicy = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Preferred)        sizePolicy.setHorizontalStretch(0)        sizePolicy.setVerticalStretch(0)        sizePolicy.setHeightForWidth(self.CompanyLogo.sizePolicy().hasHeightForWidth())        self.CompanyLogo.setSizePolicy(sizePolicy)        self.CompanyLogo.setMinimumSize(QSize(120, 80))        self.CompanyLogo.setMaximumSize(QSize(100, 80))        self.CompanyLogo.setStyleSheet(u"")        self.CompanyLogo.setPixmap(QPixmap(u":/Leica/Leica_Geosystems_without_tagline_CMYK.png"))        self.CompanyLogo.setScaledContents(True)        self.CompanyLogo.setAlignment(Qt.AlignmentFlag.AlignCenter)        self.CompanyLogo.setWordWrap(False)
              self.LeftLogo.addWidget(self.CompanyLogo)
      
              self.LeftPanel.addWidget(self.LeftLogoFrame, 0, |Qt.AlignmentFlag.AlignVCenter)
      
      
      

      Attachments

        Issue Links

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

          Activity

            People

              crmaurei Cristian Maureira-Fredes
              dk1101 Darko Kulic
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes