Skip to content

Commit 53b9e7a

Browse files
committed
(visualizer) specify height in jupyter_cell
* and also in render_static
1 parent 1793962 commit 53b9e7a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/meshcat/visualizer.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -113,20 +113,20 @@ def wait(self):
113113
"""
114114
return self.window.wait()
115115

116-
def jupyter_cell(self):
116+
def jupyter_cell(self, height=400):
117117
"""
118118
Render the visualizer in a jupyter notebook or jupyterlab cell.
119119
120120
For this to work, it should be the very last command in the given jupyter
121121
cell.
122122
"""
123123
return HTML("""
124-
<div style="height: 400px; width: 100%; overflow-x: auto; overflow-y: hidden; resize: both">
124+
<div style="height: {height}px; width: 100%; overflow-x: auto; overflow-y: hidden; resize: both">
125125
<iframe src="{url}" style="width: 100%; height: 100%; border: none"></iframe>
126126
</div>
127-
""".format(url=self.url()))
127+
""".format(url=self.url(), height=height))
128128

129-
def render_static(self):
129+
def render_static(self, height=400):
130130
"""
131131
Render a static snapshot of the visualizer in a jupyter notebook or
132132
jupyterlab cell. The resulting snapshot of the visualizer will still be an
@@ -137,10 +137,10 @@ def render_static(self):
137137
on a different machine or inside a container.
138138
"""
139139
return HTML("""
140-
<div style="height: 400px; width: 100%; overflow-x: auto; overflow-y: hidden; resize: both">
140+
<div style="height: {height}px; width: 100%; overflow-x: auto; overflow-y: hidden; resize: both">
141141
<iframe srcdoc="{srcdoc}" style="width: 100%; height: 100%; border: none"></iframe>
142142
</div>
143-
""".format(srcdoc=srcdoc_escape(self.static_html())))
143+
""".format(srcdoc=srcdoc_escape(self.static_html()), height=height))
144144

145145
def __getitem__(self, path):
146146
return Visualizer.view_into(self.window, self.path.append(path))

0 commit comments

Comments
 (0)