Script: how to parent a python GUI to the main window in Harmony 21?

Following the PyObjectWrapper examples, I managed to create a simple PySide UI and connect it to my JScript. However, the examples are probably not up to date with Python 3.9, and not entirely working.
In particular, I am not able to parent my widget to the main application.
This is the js:

function pythonScripting()
{  
  var myPythonObject = PythonManager.createPyObject("C:/dev/Harmony/scripts/python/test_2.py");
  myPythonObject.addObject("messageLog", MessageLog);
  myPythonObject.addObject("pythonManager", PythonManager);
  myPythonObject.py.createUI();
}

pythonScripting()

and this is the py:

from PySide6 import QtCore, QtWidgets, QtGui
from PySide6.QtGui import *
from PySide6.QtCore import *
from PySide6.QtWidgets import *

def createUI():
    global myU
    myUI = QWidget()
    app_widget = pythonManager.appWidget()
    myUI.setParent(app_widget)

The last line is where the problem happens, resulting in this error message:
E: 11:39:38.591 'PySide6.QtWidgets.QWidget.setParent' called with wrong argument types: PySide6.QtWidgets.QWidget.setParent(QWidget) Supported signatures: PySide6.QtWidgets.QWidget.setParent(PySide6.QtWidgets.QWidget) PySide6.QtWidgets.QWidget.setParent(PySide6.QtWidgets.QWidget, PySide6.QtCore.Qt.WindowFlags)

So, it’s like some sort of (in the C++ lingo) casting is missing between the provided PythonManager’s QWidget type and the expected PySide6.QtWidgets.QWidget one. Any idea about how to workaround the issue ? Thanks. Stefano

Hi,

I Haven’t had the chance to dive into python scripting in Harmony.
But, did you try the following?

def createUI():
    global myU

    app_widget = pythonManager.appWidget()
    myUI = QWidget(app_widget)

Thanks, Unfortunately, that gives the same type of error, this time raised by PySide6.QtWidgets.QWidget.__init__