Pyside2 module not running w. ITOM

Issue #160 resolved
Oliver Schwanke created an issue

Hi there,
i just found that pyside2 supports some sort of singal/slot mechanics for python, check this out.

Would this be possible for itom or is this a too major change?

Comments (8)

  1. M. Gronle

    What is your exact wish?

    Is it more to provide a simpler mechanism to connect existing signals of widgets (uiItems) or dataIO / actuator instances to slots (python callback methods)?
    Or do you like to have some kind of user-defined signal in Python classes, that can be connected to any other callback method?

  2. Oliver Schwanke reporter

    Well, development times with cpp are much longer than with python. So,i think the current state using itom is that only itom plugins that are also QObjects can emit signals. pyside2 is not only limited to cpp implemented QObjects, but can create classes, that are capable of emitting Signals.

    So instead of having to implement the next plugin in cpp i can write some python class and get the same functionality: transport via QT Signal/Slots.

    Am Freitag, den 19.02.2021, 13:59 +0000 schrieb M. Gronle:

  3. Bernd Bertschinger

    Pyside2 can be used as an additional module. User is able to install the module and create classes if necessary that inherit from current itom classes contain pyside2.

    No additional dependency needed here for ITOM.

  4. Bernd Bertschinger

    After installation of the PySide2 Module ITOM throws an error message, when trying to run this example:

    import sys
    from PySide2.QtWidgets import QApplication, QDialog, QLineEdit, QPushButton

    class Form(QDialog):

    def __init__(self, parent=None):
        super(Form, self).__init__(parent)
        self.setWindowTitle("My Form")
    

    if name == 'main':
    # Create the Qt Application
    app = QApplication(sys.argv)
    # Create and show the form
    form = Form()
    form.show()
    # Run the main Qt loop
    sys.exit(app.exec_())

    =======================================================================

    Traceback (most recent call last):
    File "C:\Program Files/itom (x64)/itom-packages\itomSyntaxCheck.py", line 848, in check
    style_guide = flake8GetStyleGuideItom(
    File "C:\Program Files/itom (x64)/itom-packages\itomSyntaxCheck.py", line 518, in flake8GetStyleGuideItom
    application.find_plugins(config_finder)
    File "C:\Program Files\itom (x64)\python3\lib\site-packages\flake8\main\application.py", line 157, in find_plugins
    self.check_plugins = plugin_manager.Checkers(local_plugins.extension)
    File "C:\Program Files\itom (x64)\python3\lib\site-packages\flake8\plugins\manager.py", line 363, in init
    self.manager = PluginManager(
    File "C:\Program Files\itom (x64)\python3\lib\site-packages\flake8\plugins\manager.py", line 243, in init
    self._load_entrypoint_plugins()
    File "C:\Program Files\itom (x64)\python3\lib\site-packages\flake8\plugins\manager.py", line 261, in _load_entrypoint_plugins
    eps = importlib_metadata.entry_points().get(self.namespace, ())
    File "C:\Program Files\itom (x64)\python3\lib\importlib\metadata.py", line 541, in entry_points
    ordered = sorted(eps, key=by_group)
    File "C:\Program Files\itom (x64)\python3\lib\importlib\metadata.py", line 539, in <genexpr>
    dist.entry_points for dist in distributions())
    File "C:\Program Files\itom (x64)\python3\lib\importlib\metadata.py", line 240, in entry_points
    return EntryPoint._from_text(self.read_text('entry_points.txt'))
    File "C:\Program Files\itom (x64)\python3\lib\importlib\metadata.py", line 100, in _from_text
    config.read_string(text)
    File "C:\Program Files\itom (x64)\python3\lib\configparser.py", line 723, in read_string
    self.read_file(sfile, source)
    File "C:\Program Files\itom (x64)\python3\lib\configparser.py", line 718, in read_file
    self._read(f, source)
    File "C:\Program Files\itom (x64)\python3\lib\configparser.py", line 1082, in _read
    raise MissingSectionHeaderError(fpname, lineno, line)
    configparser.MissingSectionHeaderError: File contains no section headers.
    file: '<string>', line: 1
    '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0
    ... 0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0
    ... 0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0
    ... 0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0
    ... 0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0
    ... 0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
    Traceback (most recent call last):
    File "c:\users\itoberber\documents\skripte\demo_pyside2_itom.py", line 2, in <module>
    from PySide2.QtWidgets import QApplication, QDialog, QLineEdit, QPushButton
    ImportError: DLL load failed while importing QtWidgets: Die angegebene Prozedur wurde nicht gefunden.

  5. M. Gronle

    I would say that no Python package, that is based on Qt, can be safely used within itom. Maybe there is one special usage that would work:

    If pyside2 or PyQt5/6 uses the same minor/major version of Qt (with the same build configuration) than itom uses, the Qt DLLs, used by itom, and the DLLs shipped with the Python packages are compatible, such that no DLL conflict (that is what probably happend to you @Bernd Bertschinger ) should occur. In this case, any non-GUI Qt classes can potentially be used from Python.

    However: for any QApplication instance or any QWidget / GUI based class, a direct usage within Python will possibly not work. Reasons:

    1. QApplication is a singleton. If itom is started an QApplication object is created. If you try to create another one from Python, this will either not work or the Python objects use the original QApplication from itom (which is also not desired, since it would be possible from Python so somehow corrupt the base QApplication object)
    2. Qt requires to call any GUI stuff from the main thread. The main thread is the thread, where QApplication has been created. However, Python runs within itom always in a 2nd thread, such that the main itom GUI keeps reactive, while a longer Python script is executed. That is one of the basic principles of itom: Python in its own thread and all hardware plugins in their own threads respectively. Therefore, any direct call to widget stuff in Qt from Python will fail (Qt raises an exception here).
    3. That is why we created our own GUI support within itom, also based on runtime information, delivered by Qt, signal/slots and the Qt designer.

  6. M. Gronle

    I suggest closing this issue with wont fix since I don’t know any solution for this with the current architecture of itom.

  7. Bernd Bertschinger

    Ticket closed, since this is related to the current design stage and cannot be resolved w.o. a major refactoring of all QT dependencies. This effort is already covered in ticket #231 and will be discussed as new "feature" proposal at the next developers meeting.

    Bare ITOM - w.o. QT Dependency

  8. Log in to comment