0

The below code dumps two screens, one for Tkinter and second for mayavi. How to embed mayavi inside Tkinter. Is it even possible? If not, what are the alternatives for building a GUI which has mayavi plots embeded inside a frame/canvas?

from tkinter import *
import numpy
from mayavi.mlab import *


top = Tk()


t = numpy.linspace(0, 4 * numpy.pi, 20)
cos = numpy.cos
sin = numpy.sin

x = sin(2 * t)
y = cos(t)
z = cos(2 * t)
s = 2 + sin(t)

points3d(x, y, z, s, colormap="copper", scale_factor=.25)

top.mainloop()

2 Answers2

2

Mayavi can be embedded in wxWidgets http://wxwidgets.org/ or Qt https://www.qt.io/ based GUI programs, not with Tkinter.

The relevant documentation is http://docs.enthought.com/mayavi/mayavi/building_applications.html

The documentation has also simple examples for using a controller widgets that could get you closer to a solution, if your needs are simple.

Pierre de Buyl
  • 7,074
  • 2
  • 16
  • 22
0

I would try to connect tkinter and mayavi together using this library: https://github.com/jonwright/pyopengltk

That provides OpenGL context in Tkinter window, hopefuly you will be able to pass that context to Mayavi.

Harvie.CZ
  • 73
  • 1
  • 9