SpriteActionGroup (hwx.gui)#

class SpriteActionGroup(parent=None, name='', **kwds)#

Bases: ActionGroup

A Palette of SpriteActions.

A SpriteActionGroup can be placed into a RibbonPage.

Attribute Table#

Name

Type

dropDown

property

enabled

property

visible

property

Method Table#

Name

Description

showProgress (self, value, outOf=None, tooltip=’’)

Shows a progress meter icon to the left of the label text.

Example

from hwx import gui
from hwx.gui.demo import getDemoFilePath

# Add icons to resource path
resourceFolder = getDemoFilePath('resources')
gui.addResourcePath(resourceFolder)

# Define a dialog to be toggled by a SpriteAction
class Dialog(gui.ActionDialog):
def createContents(self):
   self.addChildren("A dialog toggled by a SpriteAction in the Ribbon'")

def buildContextMenu(menu, action):
for child in action.parent.children:
   menu.insertItem(f"Simulate click on {child.tooltip}", command=child.toggle)

# A pallet with a couple of SpriteActions
group = gui.SpriteActionGroup(text="Fasteners", onContextMenu=buildContextMenu)

gui.SpriteAction(group, tooltip="Say Hello",
icon=("ribbonFastenersStrip-80.png", (0, 5)),
command=lambda: gui.tellUser("Hello World"))

gui.SpriteAction(group, tooltip="List Bolts/Pins",
icon=("ribbonSatelliteListStrip-80.png", (3, 5)), dialog=Dialog, )

# If the group has only one action, you can use a shortcut
command = gui.SpriteCommand(text="Open",
icon="ribbonFilesOpenBottomStrip-80.png",
command=lambda: gui.tellUser("Open Dialog Goes Here"), # enabled = False,
# visible = False,
)

# We can also change label to be displayed at the bottom of the group
group.text = "Fastener1"

frame = gui.HFrame(group, 10, command)

show(frame)
property visible#

The visibility of the SpriteActionGroup.

Setting to False will visually remove this from the menu/toolbar.

property enabled#

The availability of the SpriteActionGroup.

Disabled SpriteActionGroup are grayed out and the user cannot activate them.

property dropDown#

Sets the groups singular mode state. When this is set to TRUE, only one action will be displayed at a time, and the others will be available from a pull down menu accessed by clicking on the down arrow or long pressing in the group.

showProgress(value, outOf=None, tooltip='')#

Shows a progress meter icon to the left of the label text.

Parameters:
  • value (Union[float, bool]) – Upper value of progress meter.

  • outOf (float) – Factor to divide value with.

  • tooltip (str) – The tool tip to show to the user if mouse cursor is on the progress bar.