import panel as pn pn.extension()
Player widget displays media-player-like controls that allow playing and stepping through a range of values. When playing it triggers events at a pre-defined interval on the frontend, advancing the player value each time. It falls into the broad category of single-value slider widgets that provide a compatible API and includes the
For layout and styling related parameters see the customization user guide.
direction(int): Current play direction of the Player (-1: playing in reverse, 0: paused, 1: playing).
start(int): The range’s lower bound
end(int): The range’s upper bound
step(int): The interval between values
value(object): The current value; must be one of the option values
disabled(boolean): Whether the widget is editable
interval(int): Interval in milliseconds between updates
name(str): The title of the widget
loop_policy(str): Looping policy; must be one of ‘once’, ‘loop’, or ‘reflect’
show_loop_controls(boolean): Whether radio buttons allowing to switch between loop policies options are shown
The widget has a number of buttons to go to the first or last value, step forward or backward, or play and pause the widget. It also provides control over the
loop_policy which determines whether to play ‘once’, ‘loop’, or ‘reflect’. Additionally
+ buttons slow down and speed up the player speed.
player = pn.widgets.Player(name='Player', start=0, end=100, value=32, loop_policy='loop') player
Like most other widgets,
Player has a value parameter that can be accessed or set:
Player can be controlled programmatically using the
direction parameter which has three possible states:
-1: playing in reverse
Alternatively it can be controlled via the
import time player.play() time.sleep(2) player.reverse() time.sleep(2) player.pause()