RibbonPage (hwx.gui)#

class RibbonPage(name='', text='', children=(), before=None, after=None)#

Bases: object

Ribbon tab.

It is the Toolbar replacement and a Container of SpriteActionGroups and RibbonPageGroups.

Attribute Table#

Name

Type

name

property

onActivate

Signal

onDeactivate

Signal

pageMap

dict

text

property

visible

property

Method Table#

Name

Description

Activate (self) -> ‘void’

Select the page

add (self, item, after=None)

Adds the specified item to the RibbonPage.

addFrame (self, text=’’, name=’’)

Adds and returns a frame to this RibbonPage

get (name)

Lookup the RibbonPage by name.

remove (self, item)

Removes the specified item from the RibbonPage.

Example

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

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

def createRibbon(event):
#Avoid adding ribbon pages with same name. 
#Case araise with python debugger with Inspire and Compose client
if gui.RibbonPage.get('Demo Ribbon Page') : return
page = gui.RibbonPage(name='Demo Ribbon Page')

group = gui.SpriteActionGroup(page, text="Fasteners")

gui.SpriteAction(group, tooltip="Add/Edit Fasteners",
   icon=("ribbonFastenersStrip-80.png", (0, 5)),
   #  context   = BoltContext,
)

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

# Define a dialog to be toggled by a SpriteAction
class BoltTableDialog(gui.ActionDialog):
def createContents(self):
   gui.VBoxLayout(parent=self, children=(
      gui.Label('A dialog toggled by a SpriteAction in the Ribbon')))

button = gui.Button('Create Ribbon', command=createRibbon)
show(button)
property name: uiString#

Unique id used to look up page.

Type:

str

property displayName: void#

Name shown in gui that may be translated.

Type:

str

property text: void#

Name shown in gui that may be translated.

Type:

str

property visible: bool#

The visibility of the RibbonPage.

Setting it to False will visually remove it from the Ribbon.

Type:

bool

add(item, after=None)#

Adds the specified item to the RibbonPage.

Parameters:
remove(item)#

Removes the specified item from the RibbonPage.

Parameters:

item (Action | str) – The item to remove.

addFrame(text='', name='')#

Adds and returns a frame to this RibbonPage

The frame can be used to add any Widgets.

Parameters:
  • text (str) – The name/displayName of the ribbon page.

  • name (str) – The name of the Frame widget.

Returns:

The frame object added to the Ribbon page.

Return type:

Frame

activate() void#

Select the page