leon-thomm / ryvencore-qt

Qt frontend for ryvencore - Python library for building visual node editors

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support other Qt bindings

Nanguage opened this issue · comments

commented

Current implementation seems only support PySide2. Will ryvencore_qt be compatible with other Qt bindings in the future, such as PyQt5?

It will support PySide6 as well. PyQt5 has some fundamental inheritance restrictions, it basically breaks the Python language, and prevents features I need, so it probably will not be supported.

commented

Thank you for your reply. I'm curious about where PyQt differs from PySide in terms of feature implementation. Can you go into more details?

I ran into issues when using classes that derive from multiple specific PyQt5 classes (I think in my case it was QGraphicsItem and QObject). Apparently, PyQt5 does generally not support this Python feature, I was told. Of course, one can create the same with single-inheritance, but it complicates the code and you might have noticed that a lot in ryvencore-qt depends on it. However, PySide2 has substantial issues as well :/ like the QGestureRecognizer system being completely broken (since 7 years), so I cannot add sophisticated touch support.

Code I ran:

import sys
import os
os.environ['QT_API'] = 'pyside2'  # tells QtPy to use PySide2
from qtpy.QtWidgets import QMainWindow, QApplication

# ryvencore-qt
import ryvencore_qt as rc
from nodes import export_nodes


if __name__ == "__main__":

    # first, we create the Qt application and a window
    app = QApplication()
    mw = QMainWindow()

    # now we initialize a new ryvencore-qt session
    session = rc.Session()
    session.design.set_flow_theme(name='pure light')  # setting the design theme

    # and register our nodes
    session.register_nodes(export_nodes)

    # to get a flow where we can place nodes, we need to crate a new script
    script = session.create_script('hello world', flow_view_size=[800, 500])

    # getting the flow widget of the newly created script
    flow_view = session.flow_views[script]
    mw.setCentralWidget(flow_view)  # and show it in the main window

    # finally, show the window and run the application
    mw.show()
    sys.exit(app.exec_())

Error I got:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
~/.local/lib/python3.10/site-packages/qtpy/__init__.py in <module>
    209     try:
--> 210         from PySide import __version__ as PYSIDE_VERSION  # analysis:ignore
    211         from PySide.QtCore import __version__ as QT_VERSION  # analysis:ignore

ModuleNotFoundError: No module named 'PySide'

During handling of the above exception, another exception occurred:

PythonQtError                             Traceback (most recent call last)
/tmp/ipykernel_76029/2915130589.py in <module>
      2 import os
      3 os.environ['QT_API'] = 'pyside2'  # tells QtPy to use PySide2
----> 4 from qtpy.QtWidgets import QMainWindow, QApplication
      5 
      6 # ryvencore-qt

~/.local/lib/python3.10/site-packages/qtpy/__init__.py in <module>
    214         PYSIDE = True
    215     except ImportError:
--> 216         raise PythonQtError('No Qt bindings could be found')
    217 
    218 # If a correct API name is passed to QT_API and it could not be found,

PythonQtError: No Qt bindings could be found

Then I ran : pip install --upgrade PySide
and got error again :

Defaulting to user installation because normal site-packages is not writeable
Collecting PySide
  Using cached PySide-1.2.4.tar.gz (9.3 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      only these python versions are supported: [(2, 6), (2, 7), (3, 2), (3, 3), (3, 4)]
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
Note: you may need to restart the kernel to use updated packages.