AnimationToolbar (hwx.gui)#

class AnimationToolbar(parent=None, **kwds)#

Bases: Widget

An AnimationToolbar Widget.

AnimationToolbar is a widget used to display the controls for the animation.

Attribute Table#

Name

Type

animatingState

property

frame

property

timeSteps

property

Method Table#

Name

Description

addChildren (self)

Adds extra widgets.

addWidget (self, widget)

Adds a widget to the AnimationToolbar.

onAnimRangeEnabled (self, enabled)

Callback method when the animation range is enabled or disabled.

onAnimationRangeChange (self, start_frame, end_frame)

Callback method when animation range has been changed.

onFrameChange (self, frame, spontaneous)

Callback method when animation frame changes.

onPause (self)

Callback method when the animation pauses.

onResume (self)

Callback method when the animation resumes.

onStart (self)

Callback method when the animation starts.

onStop (self)

Callback method when the animation stops.

resetRange (self)

Resets the animation range.

Example

from hwx import gui

# Create a class inheriting from AnimationToolbar so that we can overload
# its callback methods
class ResultsGuideBar(gui.AnimationToolbar):

# - callbacks --------------------------------------------------------------
def onFrameChange(self, frame, spontaneous):
   # called when the Play button is clicked or when frame slider changes value
   import time
   time.sleep(0.05)
   output.text = "Play" + frame * "."

# --------------------------------------------------------------------------
def onStart(self):
   # called when the animationToolbar is instantiated
   output.text = "Starting"

# --------------------------------------------------------------------------
def onStop(self):
   # called when the Pause button on the animationToolbar is clicked
   output.text = "Stopped"

# Various options to specify a discrete list of values for timeSteps
# timeSteps=range(0, 33)
timeSteps = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

resultsToolbar = ResultsGuideBar(timeSteps=timeSteps)
resultsToolbar.show()

output = gui.Label("Stopped")
frame = gui.VFrame(resultsToolbar, output)

show(frame)
property frame: int#

The current frame.

property timeSteps#

The values for the animation time.

property animatingState#

The state of the animation.

Starts/Stops the animation.

addChildren()#

Adds extra widgets.

You need to call the addWidget method.

addWidget(widget)#

Adds a widget to the AnimationToolbar.

Parameters:

widget (Widget) – The widget to be added to the layout.

Returns:

The added widget.

Return type:

Widget

resetRange()#

Resets the animation range.

onStart()#

Callback method when the animation starts.

onStop()#

Callback method when the animation stops.

onPause()#

Callback method when the animation pauses.

onResume()#

Callback method when the animation resumes.

onFrameChange(frame, spontaneous)#

Callback method when animation frame changes.

Parameters:
  • frame (int) – Frame number changed.

  • spontaneous (bool) – Specifies if the frame change is spontaneous.

onAnimationRangeChange(start_frame, end_frame)#

Callback method when animation range has been changed.

Parameters:
  • start_frame (int) – Starting frame number of the range.

  • end_frame (int) – Ending frame number of the range.

onAnimRangeEnabled(enabled)#

Callback method when the animation range is enabled or disabled.

Parameters:

enabled (bool) – Animation range is enabled/disabled.