leon-thomm / Ryven

Flow-based visual scripting for Python
https://ryven.org
MIT License
3.76k stars 439 forks source link

Resolve Issue with multiple QT backends #166

Closed ausstein closed 11 months ago

ausstein commented 11 months ago

As written in the Issues, when installing Matplotlib, I get some qt related errors.

I think the issue is that qtpy does not choose pyside2 by default so when pyqt5 gets installed because of matplotlib, pyqt5 is chosen unless the environment variable is different.

Right now in the code

from ryven.gui_env import init_node_guis_env

from Ryven.py

and

from ryvencore_qt.src.Design import Design

from config.py get called before the environment variable is set.

Right now the choice for the QT_API is in the config.py. And the first call is also in config.py. This leaves two options to fix this:

either set the QT_API environment variable before loading the config. (In that case the qt_api value of the config would be useless)

or set the environment variable in config.py (also not ideal to do this in a config class)

I went with the latter approach for this pull request and made sure the config is loaded before init_node_guis_env is imported

leon-thomm commented 11 months ago

I think config.py imports ryvencore_qt.src.Design because the argument parser calls Config.get_available_flow_themes(). Clearly we cannot make Qt imports when we haven't even parsed arguments yet. For now I think we should just remove this invocation in args_parser.py and hard-code the themes instead.

I agree with moving down the import of the gui_env in Ryven.py, but I'm not quite sure what you intend to do with the change in config.py. As I understand it, we should remove the Qt dependency in the args parser noted above, move down the imports in run() as you did, and set QT_API from config just before that.

leon-thomm commented 11 months ago

Could you try if branch pr166_tmp works for you? If that fixes it I'll add those commits here and merge the PR.

ausstein commented 11 months ago

yes, I can confirm that the branch works! thank you!

leon-thomm commented 11 months ago

Alright, I will close this and merge pr166_tmp instead.