📜 ⬆️ ⬇️

Run Chaco and Mayavi on PySide

Well, there was the long-awaited release of PySide. Some habravchane begin to use it for the first time, some have already dealt with it.

In my work, we have to use Mayavi cross-platform visualizer and Chaco chart builder ( if you are interested, read code.enthought.com/chaco and code.enthought.com/projects/mayavi ). My task was to embed their frames in my HPGL-GUI application. Initially, I wrote everything on PyQt4 and everything suited me, except for one thing. The problem was the license. PySide is released under the LGPL v2.1, which is just right for commercial needs.

PySide came to the rescue, which has already begun to be actively used as a backend to Enthought products. It was then that the first pitfalls awaited me.
')
Lack of documentation on exactly how to use PySide for embedding.
Having a little browsing through the sources, I found out that it is enough to specify the environment variable 'QT_API' to the value 'pyside':

import os
os . environ [ 'QT_API' ] = 'pyside'

Despite this, the application refused to work. It is useful to edit the source. It seemed that there were not so many changes, but finding problems from scratch is rather disgusting and time consuming. I hope further instructions will help someone.


The first thing you need to collect packages from the gita. We set ourselves PySide, git, subversion, setuptools, swig, numpy, scipy, vtk, wxpython. For Windows, you also need to install mingw (vtk and wxpython for Win, I advise you to take from here to save time www.lfd.uci.edu/~gohlke/pythonlibs ).


After all these manipulations, you can run an example.
For Chaco: pastebin.ubuntu.com/575888
For Mayavi: pastebin.ubuntu.com/575889

Screenshots of working widgets:



PS If someone is interested, I can write articles on the possibilities and pitfalls of Chaco and Mayavi.

Source: https://habr.com/ru/post/115004/


All Articles