How to get MayaVi2 to default to/use Qt rather than wx?
Asked Answered
S

1

6

Previously I have been using a python environment maintained by Mac ports. I had some basic scripts using PyQT, VTK, matplotlib etc. I have been able to use Paraview but seem a little heavy for my uses so I though I would try MayaVi2 (and TVTK).

I downloaded and tried to manually installing but it proved troublesome. So thought I would bite the bullet and try Canopy (academic License). Based on this VTK/Mayavi on Mac OS X which suggests all is good in the world of Qt, VTK and MayaVI, I installed 64 bit Canopy.

I am having trouble getting mayavi2 to work within the Canopy environment. It runs, but the console gets lots of errors, if I call up any dialog/setting box the "buttons" don't work properly. Here is the first error (of a couple of screen fulls) when I try to start mayavi2:

(Canopy 64bit) scratch_pad 501 $mayavi2 Traceback (most recent call last): File "/Applications/Canopy.app/appdata/canopy-1.0.0.1160.macosx-x86_64/Canopy.app/Contents/lib/python2.7/site-packages/pyface/ui/wx/splash_screen.py", line 121, in _on_paint dc = wx.PaintDC(window)

I am actually more interested in TVTK, so I tried some of the mayavi demos from the website gallery http://docs.enthought.com/mayavi/mayavi/auto/examples.html The few I tried kind-a worked, that is they display a VTK (?) window/scene, I can interact with the VTK window. All is good until I open a settings/dialogue window, and then none of dialogue window "button" work and i have to force quit. Here is the last line of error when I open the "Setting" button in the plot3D demo:

simple demo: File "/Users/michael/Library/Enthought/Canopy_64bit/System/lib/python2.7/site-packages/wx/_core.py", line 9162, in DestroyChildren return core.Window_DestroyChildren(*args, **kwargs) wx._core.PyAssertionError: C++ assertion "GetEventHandler() == this" failed at /BUILD/wxPython-src-2.9.2.4/src/common/wincmn.cpp(468) in ~wxWindowBase(): any pushed event handlers must have been removed

I even tried

ipython --gui=wx

(as suggested on the page) but in this case it crashes, no window.

Based on the error messages on the console they all appear to be wx related. It is my understanding the the Canopy environment is "self-contained", but could my old environment be somehow conflicting? How would I even test this?

Is there a way, environment variable, that mayavi2 can use Qt instead of wx? I don't use wx in any of my local python scripts, so unless it is needed in Canopy I am quite happy to disable, if that is an option.

Any ideas?

Scaremonger answered 3/5, 2013 at 2:57 Comment(1)
Please post your edit as an answer, it's okay to answer your own question.Insufflate
S
9

After running most of the examples in the Mayavi Gallery I have discovered that I needed to inform Traits to use Qt. This was done by setting an environment variable from within the script using a sys.environment() call. I decided to set the environment variable ETS_TOOLKIT to qt4 in my .profile as follows:**

export ETS_TOOLKIT=qt4

Mayavi2 now works as advertised!

Scaremonger answered 4/5, 2013 at 1:42 Comment(1)
Thank you! Wx seems to be quite the hassle on OSX with anaconda's python.Scolopendrid

© 2022 - 2024 — McMap. All rights reserved.