Skip to content

Commit 25609e2

Browse files
committed
silence tvtk.pyface.ui.null backend issues
1 parent a62545a commit 25609e2

File tree

1 file changed

+36
-29
lines changed

1 file changed

+36
-29
lines changed

pytissueoptics/rayscattering/display/utils/volumeSlicer.py

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,36 @@
1616
from mayavi.core.ui.api import SceneEditor, MayaviScene, \
1717
MlabSceneModel
1818

19+
try:
20+
#---------------------------------------------------------------------------
21+
# The layout of the dialog created
22+
#---------------------------------------------------------------------------
23+
VIEW = View(HGroup(
24+
Group(
25+
Item('scene_y',
26+
editor=SceneEditor(scene_class=Scene),
27+
height=250, width=300),
28+
Item('scene_z',
29+
editor=SceneEditor(scene_class=Scene),
30+
height=250, width=300),
31+
show_labels=False,
32+
),
33+
Group(
34+
Item('scene_x',
35+
editor=SceneEditor(scene_class=Scene),
36+
height=250, width=300),
37+
Item('scene3d',
38+
editor=SceneEditor(scene_class=MayaviScene),
39+
height=250, width=300),
40+
show_labels=False,
41+
),
42+
),
43+
resizable=True,
44+
title='Volume Slicer',
45+
)
46+
except Exception as e:
47+
VIEW = e
48+
1949

2050
class VolumeSlicer(HasTraits):
2151
# The data to plot
@@ -37,13 +67,18 @@ class VolumeSlicer(HasTraits):
3767

3868
_axis_names = dict(x=0, y=1, z=2)
3969

70+
view = VIEW
71+
4072
#---------------------------------------------------------------------------
4173
def __init__(self, hist3D: np.ndarray, colormap: str = 'viridis', interpolate=False, **traits):
4274
self._colormap = colormap
4375
self._cameraView = {"azimuth": -30, "zenith": 215, "distance": None, "pointingTowards": None, "roll": -0}
4476
self._cameraPitch = -3
4577
self._interpolate = interpolate
4678

79+
if isinstance(VIEW, Exception):
80+
raise VIEW
81+
4782
super(VolumeSlicer, self).__init__(data=hist3D, **traits)
4883

4984
# Force the creation of the image_plane_widgets:
@@ -174,38 +209,10 @@ def display_scene_z(self):
174209
return self.make_side_view('z')
175210

176211

177-
#---------------------------------------------------------------------------
178-
# The layout of the dialog created
179-
#---------------------------------------------------------------------------
180-
view = View(HGroup(
181-
Group(
182-
Item('scene_y',
183-
editor=SceneEditor(scene_class=Scene),
184-
height=250, width=300),
185-
Item('scene_z',
186-
editor=SceneEditor(scene_class=Scene),
187-
height=250, width=300),
188-
show_labels=False,
189-
),
190-
Group(
191-
Item('scene_x',
192-
editor=SceneEditor(scene_class=Scene),
193-
height=250, width=300),
194-
Item('scene3d',
195-
editor=SceneEditor(scene_class=MayaviScene),
196-
height=250, width=300),
197-
show_labels=False,
198-
),
199-
),
200-
resizable=True,
201-
title='Volume Slicer',
202-
)
203-
204-
205212
if __name__ == '__main__':
206213
# Volume Slicer example with some data
207214
x, y, z = np.ogrid[-5:5:64j, -5:5:64j, -5:5:64j]
208215
data = np.sin(3 * x) / x + 0.05 * z ** 2 + np.cos(3 * y)
209216

210-
m = VolumeSlicer(data=data)
217+
m = VolumeSlicer(data)
211218
m.show()

0 commit comments

Comments
 (0)