Cura plugins + beginner Python + out dated QT= ishhh!
-
Hello,
I'm face a little problem and before we start, I'm a Assembler/C++/DirectX programmer. Python was really not my cup of tea, but don't worry about technical. The problem come went a decide to buy a FDM printer and after installing Cura, I realize that plugins was supported by the program. Then after 2 hours, I have a sort of plugins. But this one crash in a lot of circumstance. Now, What I've done.- I've already contact Ultimaker forum and Cura Working on python 3.10.4.
- Also Cura use PyQt 6.6. I use Pip Install to setup QT.
pip install PyQt6-Qt6==6.6.0 pip install PyQt6-WebEngine-Qt6==6.6.0 pip install PyQt6_sip==13.6.0 pip install PyQt6==6.6.0 pip install PyQt6-WebEngine==6.6.0
Now before integrate everything into the plugins, I've made a little demo version with Python IDLE.
import sys from PyQt6.QtWidgets import QApplication from PyQt6.QtCore import QUrl from PyQt6.QtWebEngineWidgets import QWebEngineView if __name__ == "__main__": app = QApplication(sys.argv) web_view = QWebEngineView() web_view.load(QUrl("http://192.168.1.69")) web_view.show() sys.exit(app.exec())
For the moment, this version work. but I can't make work into the plugins. And it's understandable, because plugins connect cura interface thru a instance.
CURA PLUGINSclass FluiddStage(CuraStage): """Stage for web Interface""" def __init__(self, parent = None): super().__init__(parent) Application.getInstance().engineCreatedSignal.connect(self._engineCreated) def _engineCreated(self): self.addDisplayComponent("menu", os.path.join(PluginRegistry.getInstance().getPluginPath("FluiddStage"), "FluiddMenu.qml")) self.addDisplayComponent("main", os.path.join(PluginRegistry.getInstance().getPluginPath("FluiddStage"), "FluiddMain.qml"))
Now it's here I crash... I can't create a qml version.
WebInterface.Pyfrom PyQt6.QtGui import QGuiApplication from PyQt6.QtQml import QQmlApplicationEngine from PyQt6.QtWebEngineWidgets import QWebEngineView if __name__ == "__main__": app = QGuiApplication(sys.argv) engine = QQmlApplicationEngine() engine.quit.connect(app.quit) engine.load('WebInterfaceMain.qml') sys.exit(app.exec())
WebInterfaceMain.qml
import QtQuick 2.15 import QtQuick.Controls 2.15 ApplicationWindow { visible: true width: 600 height: 500 title: "HelloApp" Text { anchors.centerIn: parent text: "Hello World" font.pixelSize: 24 } }
I try, and try and try... to insert WebEngineView into QML file nothing work... with different import to. Have you idea.... I need something like
WebView { id: webView anchors.fill: parent url: "http://192.168.1.69" }
thanks.
-
Hi and welcome to devnet,
Can you share the crash stack trace ?
Your skills hint to Windows but which OS are you using ? -
Thanks for the reply. I forgot how qt was multi-platform/multi-os. But yeah you have right, I'm running on Windows 10. Now for the crash, it's pretty funny actually. After I've move qt/bin dll into Cura root folder and some Pyd/Pyi... I didn't remember which one, i've to create a kind of cura patch file for.. but anyway.... To say after i've modified cura, i've the same bug into PythonDemo and CuraPlugins.
import os.path from UM.Application import Application from UM.PluginRegistry import PluginRegistry from cura.Stages.CuraStage import CuraStage from PyQt6.QtCore import QUrl #from PyQt6.QtWebEngineWidgets import QWebEngineView class FluiddStage(CuraStage): """Stage for web Interface""" #view = QWebEngineView() def __init__(self, parent = None): super().__init__(parent) Application.getInstance().engineCreatedSignal.connect(self._engineCreated) def _engineCreated(self): self.addDisplayComponent("menu", os.path.join(PluginRegistry.getInstance().getPluginPath("FluiddStage"), "FluiddMenu.qml")) self.addDisplayComponent("main", os.path.join(PluginRegistry.getInstance().getPluginPath("FluiddStage"), "FluiddMain.qml"))
My first plugins crash was that I cannot import QWebEngineView and I cannot create QWebEngineView() class instance. Now with cura file patch, I can. Of course I cannot use view.show() it's crash the plugins.
The second plugins crash was about QML file. I cannot import nothing, except maybe QtQuick/UM/Cura. And it's where is funny... I seem to have the same problem with my QML demo version since i try to QML the demo. I Cannot import QtWebEngine/QtWebView or whatever into QML file. it's crash demo and plugins.
Does I miss something into init.py? Remark demo folder doesn't have.