enthought / enthought/mayavi

Using mayavi plot in a sub-threading

Open
#994 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.4k
Forks
316
Avg merge
7h 44m
Merged PRs (30d)
5

Description

Hi there,
I'm trying to pack a plot function in a sub-threading, but I got an error about VTK

Here are my codes:
```python
def plot(input):
reconstruction = Reconstruction_test()
ax = plt.subplot2grid((1, 1), (0, 0), colspan=1)
# mlab.options.offscreen = True
# fig = plt.figure(1, figsize=(8, 4))
for i in range(21, 33):
x, y, z = ..., ..., ...
pts = mlab.pipeline.scalar_scatter(x, y, z)
pts.add_attribute(rgba, 'colors') # assign the colors to each point
pts.data.point_data.set_active_scalars('colors')
g = mlab.pipeline.glyph(pts)
# g.glyph.glyph.scale_factor = 0.05 # set scaling for all the points
g.glyph.glyph.scale_factor = 0.1 # set scaling for all the points
g.glyph.scale_mode = 'data_scaling_off' # make all the points same size

f = mlab.gcf()
f.scene._lift()
arr = mlab.screenshot(figure=g, mode='rgb', antialiased=True)
img_RGB = Image.fromarray(arr).convert('RGB')
ax.imshow(img_RGB)
ax.axis('off')
ax.set_title('Reconstruction')
print(i)
plt.pause(0.1)

from threading import Thread

thread1 = Thread(target=plot, args=(5,))
thread1.start()
```

However, I got an error like this:
```
2020-12-22 23:10:13.062 ( 3.453s) [ C5B32700]vtkOpenGLRenderWindow.c:93 WARN| Error invoking helper with no framebuffer
```

**Waiting for your help!! Thanks a lot!**

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.