Ribbon (hwx.gui)#

class Ribbon#

Bases: object

A Ribbon is a top level menu that appears on the main application.

Any widgets that are parented to the Ribbon appear under it. The Ribbon requires a unique identifier.

The Ribbon allows you to quickly access tools and standard functions, and is located at the top of the Inspire workspace. You can use it to add tools that you frequently use.

Attribute Table#

Name

Type

activePage

property

onActivatePage

Signal

Method Table#

Name

Description

add (location, item, **kwds)

Adds the specified item in the ribbon location.

remove (location)

Removes specified ribbon page.

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 activePage#

Currently selected page.

Type:

RibbonPage