Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Cura plugins + beginner Python + out dated QT= ishhh!
Forum Updated to NodeBB v4.3 + New Features

Cura plugins + beginner Python + out dated QT= ishhh!

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 362 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Fleuve
    wrote on last edited by
    #1

    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.

    1. I've already contact Ultimaker forum and Cura Working on python 3.10.4.
    2. 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 PLUGINS

    class 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.Py

    from 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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Can you share the crash stack trace ?
      Your skills hint to Windows but which OS are you using ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      F 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        Can you share the crash stack trace ?
        Your skills hint to Windows but which OS are you using ?

        F Offline
        F Offline
        Fleuve
        wrote on last edited by
        #3

        @SGaist

        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.

        struct.png

        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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved