Open geovogel opened 5 years ago
Hi George
I don't see anything Raspberry Pi specific in your errors. I think you should be able to do most of your design on a PC machine.
On Sunday, 23 December 2018 16:22:06 CET George wrote:
On the Raspberry pi trying to import QWT widgets from a ".ui" designer file into a python 3 script results in an import error (for example); Traceback (most recent call last): File "/home/pi/Google Drive/PythonCode/Google_API/WidgetTest.py", line 10, in
Ui_MainWindow, QtBaseClass = uic.loadUiType(DesignerFile) File "/usr/lib/python3/dist-packages/PyQt5/uic/init.py", line 201, in loadUiType exec(code_string.getvalue(), ui_globals) File " ", line 67, in ImportError: No module named 'qwt_analog_clock' The Analog Clock was implemented yesterday, so you should be able to use it with the newest git version. But pyuic5 creates code that doesn't add import Qwt and adds wrong "import qwt_xxx" lines. It needs to be edited. from PyQt5 import uic
QT SETUP
DesignerFile = "QWTwidgetTest.ui" app = QApplication(sys.argv) Ui_MainWindow, QtBaseClass = uic.loadUiType(DesignerFile) ui = UiMainWindow() window = QMainWindow() ui.setupUi(window) window.show() sys.exit(app.exec()) I don't think you can use the dynamic loading of the .ui files. You need to create the .py files, edit and import them.
Using the pyuic5 program in the following way fixes your problem, at least on Linux and systems containing grep and sed.
pyuic5 uifile.ui |grep -v "from qwt_" | sed 's/# WARNING! All changes made in this file will be lost!/from PyQt5.Qwt import */g' > ui_uifile.py
This will remove all "import qwt_" lines from your .py file and add "from PyQt5.Qwt import *" at the top of the file.
Regards Gudjon
On the Raspberry pi trying to import QWT widgets from a ".ui" designer file into a python 3 script results in an import error (for example);
Traceback (most recent call last): File "/home/pi/Google Drive/PythonCode/Google_API/WidgetTest.py", line 10, in
Ui_MainWindow, QtBaseClass = uic.loadUiType(DesignerFile)
File "/usr/lib/python3/dist-packages/PyQt5/uic/init.py", line 201, in loadUiType
exec(code_string.getvalue(), ui_globals)
File "", line 67, in
ImportError: No module named 'qwt_analog_clock'
Notes: Widgets can be generated in the python script but not imported through .ui Pi distribution is Raspberian "Stretch" Python version is 3.5.3 QT Designer version = 5.7.1 PyQt5 version is 5.7+dfsg-5 Sip Version is 4.18.1+dfsg-2
Python Script;
!/usr/bin/env python3
import sys from PyQt5 import Qwt from PyQt5.QtWidgets import * from PyQt5 import uic DesignerFile = "QWTwidgetTest.ui" app = QApplication(sys.argv) Ui_MainWindow, QtBaseClass = uic.loadUiType(DesignerFile) ui = UiMainWindow() window = QMainWindow() ui.setupUi(window) window.show() sys.exit(app.exec())