How can one use glumpy or vispy from kivy?

1.3k Views Asked by At

I am a fan of glumpy (or the related vispy), a python framework for scientific visualization. Unfortunately it does not have much in the way of user-interface (buttons etc.) I am also a fan of kivy and how it handles user interface elements. Both frameworks seem to have their own routines for drawing, window-creation etc. Can anyone point me in the right direction as to how I could use both tools in the same (desktop) app?

1

There are 1 best solutions below

2
On BEST ANSWER

I've looked into this a little. The direction I chose was to try to create a Kivy window backend for Vispy, which would use the existing Kivy window but pass through all Kivy's events (input etc) to the Vispy canvas - effectively, where a Window backend would normally have a while True: loop checking events and drawing each frame, I had a Kivy clock scheduled function doing the same thing. I think this approach should be possible and maybe fairly easy, but I'm not certain what problems could come up in integrating their eventloops. I didn't get very far with my experiments before running out of time for it.

Probably you could also do things the other way around, binding Kivy's clock tick to a timer in Vispy that runs every frame. The importance of having opengl stuff run in the right order could still cause problems, but otherwise this should also be easy, at least at a first look. I didn't try it because I'm more familiar with Kivy's internals, and because my end goal was more of a Kivy app containing Vispy visualisations rather than the other way around.

There could be other problems in combining them, like possibly general opengl problems (I think one I had was a version mismatch of opengl they were targeting) or issues with drawing order and position - I was working with the idea in mind of ideally ending up with something like a VispyWidget in Kivy, which would constrain Vispy's drawing to the given area, but I didn't get that far. I'd love to see it work though, and I think that it should be possible but would need some experimentation and maybe contributions to both projects to fix any integration issues.

Edit: The same very probably applies to glumpy, but I haven't actually tried it or looked at its code.