andreikop / qutepart

Code editor component for PyQt5
http://enki-editor.org
GNU Lesser General Public License v2.1
111 stars 30 forks source link

PySide2 Support #81

Open vivekjoshy opened 5 years ago

vivekjoshy commented 5 years ago

Does this support PySide2 yet?

andreikop commented 5 years ago

No, it doesn't. But PySide2 seems to be growing, and it's support would be useful. And I don't seen it would require a lot of time. Contributions are welcome!

srcrip commented 5 years ago

I managed to get it running with pyside2 pretty quickly. You can pretty much run a grep and replace with sed all instances of PyQt5 with PySide2. There's only two places that need a different change, and that's:

  1. Removing any importation of pyqtSignal, and then replacing calls to it with just Signal()
  2. Calling Slot instead of pyqtSlot or whatever it's called in Qt5, I can't remember.

I thought about making a branch and PR but I realized it'd just have constant merge conflicts and be hard to keep up to date. I think the best thing to do would be to take those 3 changes and throw it into a bash script that can be run on this library at any time to convert it into a PySide2 library. You really just need to replace those 3 things and it should work perfectly.

srcrip commented 5 years ago

Come to think of it, I might write up a script and put it in its own repo for converting any pyqt5 examples.

vivekjoshy commented 5 years ago

There might be a better solution than replacing the imports manually with a script every time. There is a shim library by the developers of Spyder IDE called QtPy that automatically uses PyQt or Pyside2 depending on what's available. Maybe it's possible to use it in the lib in so far as there are no PyQt specific modules being called (eg: QScintilla is not available in PySide2).

andreikop commented 5 years ago

Qutepart isn't often changed now. So, a branch should work fine. Cross-Qt solution would be even better

srcrip commented 5 years ago

The downside of using QtPy then is that if people want to integrate this into a Pyside2 project, or a pyqt5 project, they're probably going to want to continue writing the version they're using instead of the shim's syntax.

I have a suspicion that the official bindings are probably going to be slowly adopted everywhere anyways.

vivekjoshy commented 5 years ago

As far as I'm aware QtPy just simply imports the appropriate Qt bindings underneath. More testing is needed, but mixing imports from qtpy and PySide2 don't seem to be causing any issues on loading the qutepart editor.