UPDATE: I've placed print commands within the code to isolate the moment of error. The output for the below code is a b c d
. I ended up switching to pyqt/pyside using the alternative code provided, but please let me know if I can help in any other way from my current setup in debugging this issue.
from numpy import ogrid, sin
from traits.api import HasTraits, Instance
from traitsui.api import View, Item
from mayavi.sources.api import ArraySource
from mayavi.modules.api import IsoSurface
from mayavi.core.ui.api import SceneEditor, MlabSceneModel
class MayaviView(HasTraits):
scene = Instance(MlabSceneModel, ())
print "a"
view = View(Item('scene', editor=SceneEditor(), resizable=True,
show_label=False),
resizable=True)
print "b"
def __init__(self):
print "z"
HasTraits.__init__(self)
x, y, z = ogrid[-10:10:100j, -10:10:100j, -10:10:100j]
scalars = sin(x*y*z)/(x*y*z)
src = ArraySource(scalar_data=scalars)
self.scene.engine.add_source(src)
src.add_module(IsoSurface())
#-----------------------------------------------------------------------------
# Wx Code
import wx
print "c"
class MainWindow(wx.Frame):
print "d"
def __init__(self, parent, id):
print "e"
wx.Frame.__init__(self, parent, id, 'Mayavi in Wx')
self.mayavi_view = MayaviView()
self.control = self.mayavi_view.edit_traits(
parent=self,
kind='subpanel').control
self.Show(True)
app = wx.PySimpleApp()
frame = MainWindow(None, wx.ID_ANY)
app.MainLoop()
Initial Post:
I'm trying to reproduce the official code on mayaVI's website for embedding in wxWidgets (Wx embedding example).
The first error occurs while using app = wx.PySimpleApp()
, and I change it to app = wx.App(False)
via an online suggestion.
After this step, the program runs without command line error, but hangs during the data visualization step (the python visualization window never opens up, but does appear as an icon).
To test that my modules were installed correctly, I used MayaVI's official Qt example (Qt embedding example) - and it worked perfectly.
Details: I'm running Pythonw v=2.7.14 within a conda environment, with wxPython v=4.0.1 (osx-cocoa phoenix) and mayaVI v=4.5.0, all via macOS High Sierra Version 10.13.3.
Any advice on this matter would be a huge help - let me know if I can answer anything myself.