-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Add a playback button to the notebook 3d backend #8741
Changes from 16 commits
fb22fa6
b4c1d4b
5faa659
af11121
d99a10b
bda63fa
22ce2d6
0a2caf9
e7d2258
5fd78ed
4353499
66ea733
29e395c
84269cd
be61d64
1eab1dd
f4b92b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,8 @@ | |
|
||
from IPython.display import display | ||
from ipywidgets import (Button, Dropdown, FloatSlider, FloatText, HBox, | ||
IntSlider, IntText, Text, VBox, IntProgress) | ||
IntSlider, IntText, Text, VBox, IntProgress, Play, | ||
jsdlink) | ||
|
||
from ._abstract import (_AbstractDock, _AbstractToolBar, _AbstractMenuBar, | ||
_AbstractStatusBar, _AbstractLayout, _AbstractWidget, | ||
|
@@ -23,7 +24,8 @@ def _layout_initialize(self, max_width): | |
|
||
def _layout_add_widget(self, layout, widget, stretch=0): | ||
widget.layout.margin = "2px 0px 2px 0px" | ||
widget.layout.min_width = "0px" | ||
if not isinstance(widget, Play): | ||
widget.layout.min_width = "0px" | ||
children = list(layout.children) | ||
children.append(widget) | ||
layout.children = tuple(children) | ||
|
@@ -189,6 +191,12 @@ def callback(): | |
func=callback, | ||
) | ||
|
||
def _tool_bar_add_play_button(self, name, desc, func, shortcut=None): | ||
widget = Play(interval=500) | ||
self._layout_add_widget(self._tool_bar_layout, widget) | ||
self.actions[name] = widget | ||
return _IpyWidget(widget) | ||
|
||
def _tool_bar_set_theme(self, theme): | ||
pass | ||
|
||
|
@@ -224,8 +232,15 @@ def _status_bar_update(self): | |
|
||
|
||
class _IpyPlayback(_AbstractPlayback): | ||
def _playback_initialize(self, func, timeout): | ||
pass | ||
def _playback_initialize(self, func, timeout, value, rng, | ||
time_widget, play_widget): | ||
play = play_widget._widget | ||
play.min = rng[0] | ||
play.max = rng[1] | ||
play.value = value | ||
slider = time_widget._widget | ||
jsdlink((play, 'value'), (slider, 'value')) | ||
jsdlink((slider, 'value'), (play, 'value')) | ||
|
||
|
||
class _IpyMplInterface(_AbstractMplInterface): | ||
|
@@ -348,7 +363,7 @@ def show(self): | |
except RuntimeError: | ||
# pyvista>=0.30.0 | ||
viewer = self.plotter.show( | ||
jupyter_backend="ipyvtk_simple", return_viewer=True) | ||
jupyter_backend="ipyvtklink", return_viewer=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes but I'm thinking that it should also work for people with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I plan to bump/update those requirements in #9341 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it's only a line or two to keep it working, it would be nice not to force people to upgrade There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But if they have
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I understand There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll rework this part to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The API changed too, the following won't work:
|
||
viewer.layout.width = None # unlock the fixed layout | ||
# main widget | ||
if self._dock is None: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like this block works for >= 0.30 and < 0.30
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this one does not depend on another package.
If the user does not have
ipyvtklink
but haspyvista 0.30.0
, it just won't work.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's why I think bumping is the least painful solution