You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running;
Python 3.11.2 (tags/v3.11.2:878ead1, Feb 7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)] on win32
Python 3.11.2 (main, Feb 9 2023, 15:00:29) [GCC 10.2.1 20210110] on linux
QtPy==2.3.0
PySide6==6.4.2
I used Qt Designer to create a simple Main Window with a QWebEngineView and saved it as untitled.ui which is zipped and attached; untitled.zip
Now when untitled.ui is loaded using qtpy.uic.loadUi an exception is raised;
Traceback (most recent call last):
File "C:\Temp\issue.py", line 10, in <module>
widget = loadUi(r"untitled.ui") # This results in a ModuleNotFoundError.
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\python311\Lib\site-packages\qtpy\uic.py", line 237, in loadUi
customWidgets = _get_custom_widgets(uifile)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\python311\Lib\site-packages\qtpy\uic.py", line 207, in _get_custom_widgets
module = importlib.import_module(cw_header)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\python311\Lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1142, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'QtWebEngineWidgets/QWebEngineView'
With PySide6.QtUiTools.QUiLoader, untitled.ui loads as expected.
is attempting to manually load the Python modules corresponding to the Qt headers listed under the custom widgets section in the ui file, but naively doing so in a way that won't actually work with a location type spec.
Namely, it attempts to load the relative path to the header as a single Python module, when in fact it is only the first element of the path before the / that is the actual module name. Furthermore, it doesn't not properly specify this as a submodule of the currently selected binding (namely PySide6 in your case), but rather as a top-level standalone module, which also wouldn't work.
However, recommending a desired solution is well beyond my subject matter expertise. @dalthviz ?
Quite late but checking seems like we should thoroughly review the UiLoader class and loadUi definitions (I think those definitons come from efforts to support PySide and PySide2 compatibility and seems like they were meant to work following the behavior of PyQt4 🤔). Also, we should not use them for PySide6 and instead do some changes similar to what was done for loadUiType at #440
Running;
Python 3.11.2 (tags/v3.11.2:878ead1, Feb 7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)] on win32
Python 3.11.2 (main, Feb 9 2023, 15:00:29) [GCC 10.2.1 20210110] on linux
QtPy==2.3.0
PySide6==6.4.2
I used Qt Designer to create a simple Main Window with a QWebEngineView and saved it as untitled.ui which is zipped and attached;
untitled.zip
Now when untitled.ui is loaded using qtpy.uic.loadUi an exception is raised;
With PySide6.QtUiTools.QUiLoader, untitled.ui loads as expected.
See attached issue.py; issue.zip
The text was updated successfully, but these errors were encountered: