tags:

views:

421

answers:

2

How do you embed a vpython plot (animated) within your Qt GUI? so that it has its own display area and would not need to created a new window anymore.

+3  A: 

vpython's FAQs claim that vpython's architecture make any embedding a problem...:

Q: Is there a way to embed VPython in another environment?

This is difficult because VPython has two threads, your computational thread and a rendering thread which about 25 times per second paints the scene using the current attributes of the graphics objects. However, Stef Mientki has managed to embed VPython in a wxPython window on Windows; see the contributed section.

So if with wxPython it takes heroic efforts ("has managed to" doesn't sound like a trivial achievement;-) AND only works on a single platform, I fear it won't be any easier with Qt... one hard, uphill slog separately on each and every single platform.

If you're up for a SERIOUS challenge, deeply familiar with vpython, reasonably familiar with Qt, and acquainted with the underlying window-level architecture on all platforms you care about (and with a minor in wxPython), the place to start is Mientki's amazing contribution. He's actually working well below wxPython's level of abstraction, and in terms of win32gui calls, win32con constants, plus "a finite state-machine, clocked by a wx.Timer" at 100 milliseconds (though he does admit that the result from the latter Frankenstein surgery is... "not perfect";-). Extremely similar approaches should see you home (in a similarly "not perfect" way) on any other framework on Windows, including Qt.

However, nobody's yet offered any ports of this to Mac OS X, nor to any window manager of the many that are popular on Linux and Unix-like architectures (I'm not sure whether the feat could be achieved just at xlib level -- window decoration aspects do seem to be involved, and in the X11 world those DO tend to need window manager cooperation).

So, the literal answer to your question is, "with a huge amount of work requiring lots of skills and/or incredible perseverance, and probably in a platform-dependent way that will require redoing on each and every platform of interest"... sorry to be the bearer of pretty bad news, but I prefer to call them as I see them.

Alex Martelli
A: 

I contacted maintainer of VPython and he confirmed, that he is not aware of any working solution where Visual is embedded into QT window.

That turned me to try VTK and so far I'm pretty happy, no problem with using VTK within PyQT framework.

piobyz