@@ -200,13 +200,17 @@ def _make_viewer(figure, n_row, n_col, title, scene_size, offscreen,
200
200
if figure is None :
201
201
# spawn scenes
202
202
h , w = scene_size
203
- if offscreen is True :
203
+ if offscreen == 'auto' :
204
+ offscreen = mlab .options .offscreen
205
+ if offscreen :
204
206
orig_val = mlab .options .offscreen
205
- mlab .options .offscreen = True
206
- with warnings .catch_warnings (record = True ): # traits
207
- figures = [[mlab .figure (size = (h / n_row , w / n_col ))
208
- for _ in range (n_col )] for __ in range (n_row )]
209
- mlab .options .offscreen = orig_val
207
+ try :
208
+ mlab .options .offscreen = True
209
+ with warnings .catch_warnings (record = True ): # traits
210
+ figures = [[mlab .figure (size = (h / n_row , w / n_col ))
211
+ for _ in range (n_col )] for __ in range (n_row )]
212
+ finally :
213
+ mlab .options .offscreen = orig_val
210
214
_v = None
211
215
else :
212
216
# Triage: don't make TraitsUI if we don't have to
@@ -356,10 +360,11 @@ class Brain(object):
356
360
surface where hemispheres typically overlap (Default: True)
357
361
show_toolbar : bool
358
362
If True, toolbars will be shown for each view.
359
- offscreen : bool
363
+ offscreen : bool | str
360
364
If True, rendering will be done offscreen (not shown). Useful
361
365
mostly for generating images or screenshots, but can be buggy.
362
- Use at your own risk.
366
+ Use at your own risk. Can be "auto" (default) to use
367
+ ``mlab.options.offscreen``.
363
368
interaction : str
364
369
Can be "trackball" (default) or "terrain", i.e. a turntable-style
365
370
camera.
@@ -387,7 +392,7 @@ def __init__(self, subject_id, hemi, surf, title=None,
387
392
cortex = "classic" , alpha = 1.0 , size = 800 , background = "black" ,
388
393
foreground = None , figure = None , subjects_dir = None ,
389
394
views = ['lat' ], offset = True , show_toolbar = False ,
390
- offscreen = False , interaction = 'trackball' , units = 'mm' ):
395
+ offscreen = 'auto' , interaction = 'trackball' , units = 'mm' ):
391
396
392
397
if not isinstance (interaction , string_types ) or \
393
398
interaction not in ('trackball' , 'terrain' ):
0 commit comments