GuideBar (hwx.gui)#

class GuideBar(relativeto=None, **kwds)#

Bases: Container

A popup dialog.

It is typically used in a context to guide a user though the workflow.

Attribute Table#

Name

Type

activebutton

property

position

property

Method Table#

Name

Description

button (self, **kwds)

Adds a button to self.

buttonGroup (self, buttons, **kwds)

Groups all the buttons specified in a ButtonGroup.

comboBox (self, **kwds)

Creates a new ComboButton and inserts it into self.

executeCreateandExitButton (self, command, **kwds)

Shortcut for creating green check button that

executePlayButton (self, command, **kwds)

Shortcut for creating a play button that executes the given command.

exitButton (self, **kwds)

Shortcut for creating a button that has the red x icon and pops the

legend (self, values, delayShow=False, **kwds)

Sets and returns the legends.

menu (self, autoshow=True, autohide=True, **kwds)

Creates a new menu button.

resetButton (self, **kwds)

Shortcut for creating a button that has the reset icon and calls

toggleButton (self, **kwds)

Creates a new ToggleButton and inserted into self.

widget (self, widget, stretch=0)

Adds a widget to self.

Example

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

file = getDemoFilePath('M01_FourBar.x_b')
model = inspire.openFile(file)

class GuideBar(gui.GuideBar):

  def createContents(self):        
    self.greyed = self.button(
      text = "Greyed out",
      tooltip = "You can't use this button.",
      enabled = False
    )

    #Clicking this clears pick and select lists
    self.resetButton()

    self.combo = self.comboBox(
      values  = (
        ("Aligned Holes", "Aligned Holes"),
        ("Single Holes" , "Single Holes" ),
      ))

    self.message = self.executePlayButton(
            command = self.context.pickJoint,
            tooltip = "Show the joints of selected hole type",
    )

    self.back = self.button(
            icon = "previous",
            command = lambda: self.context.isolateCandidates(False),
            tooltip = "Go to Previous Location",
    )

    self.forward = self.button(
            icon = "next",
            command = lambda: self.context.isolateCandidates(True),
            tooltip = "Go to Next Location",
    )

    self.executeCreateandExitButton(
            command = self.context.createJoint,
            tooltip = "Create the joints",
    )

    self.exitButton()

class GuideBarDemoContext(gui.Context):
  def onActivate(self, firstTime):
    if firstTime:
      self.guideBar = GuideBar(self)
    self.guideBar.show()

  def pickJoint(self):
    self.clearPickList()
    if self.guideBar.combo.value == "Aligned Holes":
      self.setPickable(picked=inspire.Holes().aligned)
    else:
      self.setPickable(picked=inspire.Holes().singular)

  def createJoint(self):
    for connection in self.getPickedObjects():
      joint = inspire.Joint (connection)

  def isolateCandidates(self, forward):
    super().isolatePicked(forward, self.getPickedObjects())

GuideBarDemoContext.push()
widget(widget, stretch=0)#

Adds a widget to self.

Parameters:
  • widget (Widget) – The widget to add to the layout. It is expected to be a child of the wrapped widget.

  • stretch (int) – The stretch value of the widget that will be added.

Returns:

The added widget.

Return type:

Widget

button(**kwds)#

Adds a button to self.

Returns:

The added button.

Return type:

Button

executePlayButton(command, **kwds)#

Shortcut for creating a play button that executes the given command.

Parameters:

command (callback) – Callback method to be called when the button is clicked.

Returns:

The new play button.

Return type:

Button

executeCreateandExitButton(command, **kwds)#
Shortcut for creating green check button that

executes the command, calls clearAllLists, then calls .pop().

Parameters:

command (callback) – Callback method to be called when the button is clicked.

Returns:

A check button.

Return type:

Button

resetButton(**kwds)#
Shortcut for creating a button that has the reset icon and calls

clearAllLists.

Returns:

The new reset button.

Return type:

Button

exitButton(**kwds)#
Shortcut for creating a button that has the red x icon and pops the

context.

Parameters:

kwds (dict) – Any other properties user wants to set for the exit button.

Returns:

The new exit button.

Return type:

Button

toggleButton(**kwds)#

Creates a new ToggleButton and inserted into self.

Parameters:

kwds (dict) – Any other properties user wants to set for the ToggleButton.

Returns:

The new ToggleButton.

Return type:

ToggleButton

comboBox(**kwds)#

Creates a new ComboButton and inserts it into self.

Parameters:

kwds (dict) – Any other properties user wants to set for the ComboButton.

Returns:

The new ComboButton.

Return type:

ComboButton

legend(values, delayShow=False, **kwds)#

Sets and returns the legends.

Parameters:
  • values (LegendWidget) – Legend widgets to be added in guide bar.

  • delayShow (bool) – Determines whether to delay the showing of the legends or not.

  • kwds (dict) – Any other properties user wants to set for the legend.

Returns:

All the legends.

Return type:

Legend

menu(autoshow=True, autohide=True, **kwds)#

Creates a new menu button.

Parameters:
  • autoshow (bool) – Determines whether to automatically show the menu button or not.

  • autohide (bool) – Determines whether to automatically hide the menu button or not.

  • kwds (dict) – Any other properties user wants to set for the menu button.

Returns:

A menu button.

Return type:

Button

buttonGroup(buttons, **kwds)#

Groups all the buttons specified in a ButtonGroup.

Parameters:
  • buttons (list[Button]) – List of buttons to be added to the group.

  • kwds (dict) – Any other properties needed to be set for the ButtonGroup.

Returns:

A ButtonGroup.

Return type:

ButtonGroup

property position#

Alignment relative to its captor:

  • Floating

  • TopLeft

  • TopRight

  • BottomLeft

  • BottomRight

  • BottomCenter

  • RelativePosition

property activebutton#

Returns or sets the button, whose help-text will be shown.