Details
Description
Hi, when using Qt Designer to create UI files and then using pyside2-uic to generate the python files, pyside2-uic does not generate the QtWebKit or QQuickWidget import statements correctly and puts them at the bottom of the file.
for example, when trying to use a QWebview from qt designer, pyside2-uic generates this at the bottom:
from PySide2 import QtWebKit
this then causes issues when running as the webview that is from QtWebKit is in another place in pyside2, and i have to manually copy this in instead and remove the old module import:
from PySide2.QtWebEngineWidgets import QWebEngineView
here is a stack trace if that's helpful:
Traceback (most recent call last): File "/home/jack/code/repos/nexus-constructor/main.py", line 11, in <module> from ui.addcomponent import Ui_AddComponentDialog File "/home/jack/code/repos/nexus-constructor/ui/addcomponent.py", line 175, in <module> from PySide2 import QtWebKit ImportError: cannot import name 'QtWebKit' from 'PySide2' (/home/jack/.local/lib/python3.7/site-packages/PySide2/_init_.py) Error in sys.excepthook: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook from apport.fileutils import likely_packaged, get_recent_crashes File "/usr/lib/python3/dist-packages/apport/_init_.py", line 5, in <module> from apport.report import Report File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module> import apport.fileutils File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module> from apport.packaging_impl import impl as packaging File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module> import apt File "/usr/lib/python3/dist-packages/apt/_init_.py", line 23, in <module> import apt_pkg ModuleNotFoundError: No module named 'apt_pkg' Original exception was: Traceback (most recent call last): File "/home/jack/code/repos/nexus-constructor/main.py", line 11, in <module> from ui.addcomponent import Ui_AddComponentDialog File "/home/jack/code/repos/nexus-constructor/ui/addcomponent.py", line 175, in <module> from PySide2 import QtWebKit ImportError: cannot import name 'QtWebKit' from 'PySide2' (/home/jack/.local/lib/python3.7/site-packages/PySide2/_init_.py)
Would be really nice to just generate the files and not have to modify them afterwards, if a UI file contains lots of web views or qquickwidgets these will have to be changed every time.
Attachments
Issue Links
- duplicates
-
PYSIDE-797 Rewrite pyside-uic
- Closed