Containers#
CollapsibleFrame Class#
- class CollapsibleFrame(*args: Any, **kwargs: Any)#
A Frame with a flat button and subfame that is toggled visible/invisible as the label is clicked.
The button causes the container to expand or contract. It is used when there is a need to consolidate and hide/show grouped widgets.
from hwx import gui # Create various widgets and arrange them in a collapsible frame container icon = gui.IconLabel(icon=("toolbarAnimationSettingsStrip-24.png", (7, 0)), size=(48, 48)) speedAccuracy = gui.VRadioButtons( values=(("faster", "Faster"), ("accurate", "More Accurate"),)) layout = gui.HBoxLayout((icon, 40, speedAccuracy)) frame = gui.CollapsibleFrame(text="Speed Accuracy Settings", expanded=False, # initial configuration of the CollapsibleFrame children=(layout)) show(frame)
- addChildren(children)#
Add child widgets/layouts into this widget.
Widget children get layed out using a VBoxLayout.
Typically, you’ll pass the parent/children into the constructor instead of calling this function directly.
- Parameters:
children (list[Widget] | Layout) –
- destroy()#
Deletes this and all its children.
- enableGlobalActions(enable)#
Sets the state of Global Actions.
Disable the global actions to get key events.
- Parameters:
enable (bool) – Determines whether to enable or disable global actions.
- getMousePosition()#
Returns the mouse position.
- getRelativeMousePosition()#
Returns the mouse position relative to this widget.
- hide()#
Hides the widget.
- classmethod resizeForAlignment(frames, val=35)#
Adjust sizes so things line up
- saveAsPng(fname)#
Saves the widget as a .png file.
- Parameters:
fname (str) – The file name for the .png
- Returns:
True if it was saved succesfully, False otherwise.
- Return type:
bool
- setF1HelpTopic(helptopic)#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- setProperties(kwds)#
Internal method called from constructors.
- show()#
Shows the widget.
- unitManager()#
(hwx.common.Units) Unit manager used to format floats with units
- property active#
Returns True if it is visible and enabled, False otherwise. (readonly property)
- property advancedTooltip#
The advanced tooltip that appears while hovering mouse over widget.
- property children#
All widgets immediately contained by this one.
- property command#
Method called when the widget is activated or changed.
- property descendents#
All the widgets ultimately contained by this one.
- property enabled#
The availability of the widget.
Disabled widgets are greyed out and don’t respond to input events.
- property font#
The font used in this widget (set with font or dict).
- property frameShape#
Returns frame shape from the frame style. Below are the valid frame shape: - NOFRAME - BOX - PANEL - WINPANEL - HLINE - VLINE - STYLEDPANEL
- property height#
Fixed height of the widget.
- property helpTopic#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- property layout#
The layout that contains this widget’s children.
- property maximumHeight#
The maximum allowable height inside the Layout.
- property maximumWidth#
The maximum allowable width inside the Layout.
- property minimumHeight#
The smallest allowable height inside the Layout.
- property minimumWidth#
The smallest allowable width inside the Layout.
- property name#
The unique identifier within a container.
- property parent#
The container that owns this widget.
- property size#
The fixed size of the widget (width, height).
- property text#
Returns and sets the text of the CollapsibleFrame.
- property tooltip#
The tooltip that appears while hovering mouse over widget.
- property value#
The value of the widget.
- property visible#
The visibility of the widget.
- property width#
The fixed width of the widget.
If a string or list of strings are specified, the width will be calculated from the longest string given the font.
CsvFileDialog Class#
- class CsvFileDialog#
A Dialog that prompts for read/write csv file names.
It remembers the last directory a csv file was read/written.
- classmethod getOpenFileName(filter='Comma Separated Values (*.csv)', remember='write_csv', **kwds)#
Returns the csv filename opened.
- classmethod getSaveFileName(filter='Comma Separated Values (*.csv)', remember='write_csv', **kwds)#
Returns the csv filename saved.
Dialog Class#
- class Dialog(*args: Any, **kwargs: Any)#
A top-level window mostly used for short-term tasks and brief communications with the user.
from hwx import gui # This method is called when you click on 'Close'. def onClose(event): gui.tellUser('Distance is %s' % distance.value) dialog.hide() distance = gui.DoubleEdit(9.81, units='length') height = gui.DoubleEdit(2.91, units='length') close = gui.Button('Close', command=onClose) # Create a dialog box containing the above widgets dialog = gui.Dialog( caption="The distance", children=( gui.GridFrame( ("Distance", 5, distance), ("Height", 5, height) ), 5, ("<->", close) ) ) # to show the dialog as a non-modal dialog # dialog.show() show(dialog)
- class TitleBar_(*args: Any, **kwargs: Any)#
- addChildren(children)#
Add child widgets/layouts into this widget.
Widget children get layed out using a VBoxLayout.
Typically, you’ll pass the parent/children into the constructor instead of calling this function directly.
- Parameters:
children (list[Widget] | Layout) –
- button(icon, command, **kwds)#
A method for adding buttons to the title bar of the dialog.
- Parameters:
icon (str) –
command (callback) – Callback method to be called when the button is clicked.
kwds (dict) – Any properties user wants to set for the button.
- Returns:
ToolButton
- destroy()#
Deletes this and all its children.
- enableGlobalActions(enable)#
Sets the state of Global Actions.
Disable the global actions to get key events.
- Parameters:
enable (bool) – Determines whether to enable or disable global actions.
- executeCreateandExitButton(command, **kwds)#
Shortcut for creating green check button.
- Parameters:
command (callback) – Callback method to be called when the button is clicked.
- Returns:
A check button.
- Return type:
- executePlayButton(command, **kwds)#
Shortcut for creating a button that has the play icon
- Parameters:
command (callback) – Callback method to be called when the button is clicked.
kwds (dict) – Any property the user wants to set for the button.
- Returns:
ToolButton
- exitButton(**kwds)#
Shortcut for creating a button that has the red x icon.
- Parameters:
kwds (dict) – Any other properties user wants to set for the exit button.
- Returns:
The new exit button.
- Return type:
- getMousePosition()#
Returns the mouse position.
- getRelativeMousePosition()#
Returns the mouse position relative to this widget.
- hide()#
Hides the widget.
- maximizeRestoreButton(maximizeText=hwui.uiManager.Get.Application.Translate, restoreText=hwui.uiManager.Get.Application.Translate)#
Adds a maximize and a restore tool button and implements the expected behavior when these are clicked.
- Parameters:
maximizeText (str) – The tooltip of maximize button.
restoreText (str) – The tooltip of restore button.
- Returns:
A list containing the maximize and minimize buttons.
- Return type:
- resetButton(command, **kwds)#
Shortcut for creating a button that has the reset icon.
- Returns:
The new reset button.
- Return type:
- saveAsPng(fname)#
Saves the widget as a .png file.
- Parameters:
fname (str) – The file name for the .png
- Returns:
True if it was saved succesfully, False otherwise.
- Return type:
bool
- setF1HelpTopic(helptopic)#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- setProperties(kwds)#
Internal method called from constructors.
- show()#
Shows the widget.
- unitManager()#
(hwx.common.Units) Unit manager used to format floats with units
- property active#
Returns True if it is visible and enabled, False otherwise. (readonly property)
- property advancedTooltip#
The advanced tooltip that appears while hovering mouse over widget.
- property children#
All widgets immediately contained by this one.
- property command#
Method called when the widget is activated or changed.
- property descendents#
All the widgets ultimately contained by this one.
- property enabled#
The availability of the widget.
Disabled widgets are greyed out and don’t respond to input events.
- property font#
The font used in this widget (set with font or dict).
- property frameShape#
Returns frame shape from the frame style. Below are the valid frame shape: - NOFRAME - BOX - PANEL - WINPANEL - HLINE - VLINE - STYLEDPANEL
- property height#
Fixed height of the widget.
- property helpTopic#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- property layout#
The layout that contains this widget’s children.
- property maximumHeight#
The maximum allowable height inside the Layout.
- property maximumWidth#
The maximum allowable width inside the Layout.
- property minimumHeight#
The smallest allowable height inside the Layout.
- property minimumWidth#
The smallest allowable width inside the Layout.
- property name#
The unique identifier within a container.
- property parent#
The container that owns this widget.
- property size#
The fixed size of the widget (width, height).
- property tooltip#
The tooltip that appears while hovering mouse over widget.
- property value#
The value of the widget.
- property visible#
The visibility of the widget.
- property width#
The fixed width of the widget.
If a string or list of strings are specified, the width will be calculated from the longest string given the font.
- accept(returnValue)#
Close the dialog and returnValue from exec.
- addChildren(children)#
Add child widgets/layouts into this widget.
Widget children get layed out using a VBoxLayout.
Typically, you’ll pass the parent/children into the constructor instead of calling this function directly.
- Parameters:
children (list[Widget] | Layout) –
- createContents()#
To be implemented in derived class.
- destroy()#
Deletes this and all its children.
- enableGlobalActions(enable)#
Sets the state of Global Actions.
Disable the global actions to get key events.
- Parameters:
enable (bool) – Determines whether to enable or disable global actions.
- exec()#
Show as a model dialog, blocking code execution until it is closed.
This is typically used to get user input before continuing. Dialog code returns the input from exec by calling self.accept(value).
- Returns:
The accepted value or None if the dialog is closed in any other way.
- classmethod get()#
Get singleton when dialog is implemented as a subclass
Used by associated Button/SpriteActions.
- getMousePosition()#
Returns the mouse position.
- getRelativeMousePosition()#
Returns the mouse position relative to this widget.
- hide()#
Hides the widget.
- positionUnder(relativeTo, checkWasMoved=True, xoffset=0)#
Positions the dialog under or over the relataveTo widget.
- Parameters:
relativeTo (Widget) – The widget to position relative to.
checkWasMoved (bool) – Determines whether to check if widget is moved or not.
xoffset (int) – The offset value for the widget for x-axis.
- reject()#
Syntactic sugar to close the exec dialog without accepting a value. None is returned from exec.
- resize(width, height)#
Resize width/height of dialog.
This does not prevent the user from manually resizing like setting the width/height does.
- saveAsPng(fname)#
Saves the widget as a .png file.
- Parameters:
fname (str) – The file name for the .png
- Returns:
True if it was saved succesfully, False otherwise.
- Return type:
bool
- setF1HelpTopic(helptopic)#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- setProperties(kwds)#
Internal method called from constructors.
- show()#
Shows the dialog and continues with script execution.
- unitManager()#
(hwx.common.Units) Unit manager used to format floats with units
- property active#
Returns True if it is visible and enabled, False otherwise. (readonly property)
- property advancedTooltip#
The advanced tooltip that appears while hovering mouse over widget.
The text displayed in the titlebar.
- property children#
All widgets immediately contained by this one.
- property closeOnEscape#
The behavior when the user presses the Esc key in a dialog.
- property command#
Method called when the widget is activated or changed.
- property descendents#
All the widgets ultimately contained by this one.
- property enabled#
The availability of the widget.
Disabled widgets are greyed out and don’t respond to input events.
- property font#
The font used in this widget (set with font or dict).
- property height#
Fixed height of the widget.
- property helpTopic#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- property layout#
Layout for the content area of the dialog.
Children widgets get added here.
- property maximumHeight#
The maximum allowable height inside the Layout.
- property maximumWidth#
The maximum allowable width inside the Layout.
- property minimumHeight#
The smallest allowable height inside the Layout.
- property minimumWidth#
The smallest allowable width inside the Layout.
- property name#
The unique identifier within a container.
- property parent#
The container that owns this widget.
- property position#
The location within the main window.
- property size#
The fixed size of the widget (width, height).
- property title#
The text displayed in the titlebar.
- property tooltip#
The tooltip that appears while hovering mouse over widget.
- property value#
The value of the widget.
- property visible#
The visibility of the dialog.
- property width#
The fixed width of the widget.
If a string or list of strings are specified, the width will be calculated from the longest string given the font.
DockWindow Class#
- class DockWindow(*args: Any, **kwargs: Any)#
A dockable window.
It can exist in a floating state or can be attached to the main application window.
from hwx import gui window = gui.DockWindow( caption="Run", docked=False, children=gui.VFrame( gui.Label(icon="ribbonPrimitivesSphereStrip-64.png"), gui.Label(icon="ribbonPrimitivesStrip-80.png"), gui.Label(icon="ribbonPrimitivesTorusStrip-64.png") ), height=200, width=150 ) window.titleBar.exitButton() window.show()
- class DockArea(*args: Any, **kwargs: Any)#
- class TitleBar_(*args: Any, **kwargs: Any)#
- addChildren(children)#
Add child widgets/layouts into this widget.
Widget children get layed out using a VBoxLayout.
Typically, you’ll pass the parent/children into the constructor instead of calling this function directly.
- Parameters:
children (list[Widget] | Layout) –
- button(icon, command, **kwds)#
A method for adding buttons to the title bar of the dialog.
- Parameters:
icon (str) –
command (callback) – Callback method to be called when the button is clicked.
kwds (dict) – Any properties user wants to set for the button.
- Returns:
ToolButton
- destroy()#
Deletes this and all its children.
- enableGlobalActions(enable)#
Sets the state of Global Actions.
Disable the global actions to get key events.
- Parameters:
enable (bool) – Determines whether to enable or disable global actions.
- executeCreateandExitButton(command, **kwds)#
Shortcut for creating green check button.
- Parameters:
command (callback) – Callback method to be called when the button is clicked.
- Returns:
A check button.
- Return type:
- executePlayButton(command, **kwds)#
Shortcut for creating a button that has the play icon
- Parameters:
command (callback) – Callback method to be called when the button is clicked.
kwds (dict) – Any property the user wants to set for the button.
- Returns:
ToolButton
- exitButton(**kwds)#
Shortcut for creating a button that has the red x icon.
- Parameters:
kwds (dict) – Any other properties user wants to set for the exit button.
- Returns:
The new exit button.
- Return type:
- getMousePosition()#
Returns the mouse position.
- getRelativeMousePosition()#
Returns the mouse position relative to this widget.
- hide()#
Hides the widget.
- maximizeRestoreButton(maximizeText=hwui.uiManager.Get.Application.Translate, restoreText=hwui.uiManager.Get.Application.Translate)#
Adds a maximize and a restore tool button and implements the expected behavior when these are clicked.
- Parameters:
maximizeText (str) – The tooltip of maximize button.
restoreText (str) – The tooltip of restore button.
- Returns:
A list containing the maximize and minimize buttons.
- Return type:
- resetButton(command, **kwds)#
Shortcut for creating a button that has the reset icon.
- Returns:
The new reset button.
- Return type:
- saveAsPng(fname)#
Saves the widget as a .png file.
- Parameters:
fname (str) – The file name for the .png
- Returns:
True if it was saved succesfully, False otherwise.
- Return type:
bool
- setF1HelpTopic(helptopic)#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- setProperties(kwds)#
Internal method called from constructors.
- show()#
Shows the widget.
- unitManager()#
(hwx.common.Units) Unit manager used to format floats with units
- property active#
Returns True if it is visible and enabled, False otherwise. (readonly property)
- property advancedTooltip#
The advanced tooltip that appears while hovering mouse over widget.
- property children#
All widgets immediately contained by this one.
- property command#
Method called when the widget is activated or changed.
- property descendents#
All the widgets ultimately contained by this one.
- property enabled#
The availability of the widget.
Disabled widgets are greyed out and don’t respond to input events.
- property font#
The font used in this widget (set with font or dict).
- property frameShape#
Returns frame shape from the frame style. Below are the valid frame shape: - NOFRAME - BOX - PANEL - WINPANEL - HLINE - VLINE - STYLEDPANEL
- property height#
Fixed height of the widget.
- property helpTopic#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- property layout#
The layout that contains this widget’s children.
- property maximumHeight#
The maximum allowable height inside the Layout.
- property maximumWidth#
The maximum allowable width inside the Layout.
- property minimumHeight#
The smallest allowable height inside the Layout.
- property minimumWidth#
The smallest allowable width inside the Layout.
- property name#
The unique identifier within a container.
- property parent#
The container that owns this widget.
- property size#
The fixed size of the widget (width, height).
- property tooltip#
The tooltip that appears while hovering mouse over widget.
- property value#
The value of the widget.
- property visible#
The visibility of the widget.
- property width#
The fixed width of the widget.
If a string or list of strings are specified, the width will be calculated from the longest string given the font.
- addChildren(children)#
Add child widgets/layouts into this widget.
Widget children get layed out using a VBoxLayout.
Typically, you’ll pass the parent/children into the constructor instead of calling this function directly.
- Parameters:
children (list[Widget] | Layout) –
- createContents()#
To be implemented in derived class.
- destroy()#
Deletes this and all its children.
- enableGlobalActions(enable)#
Sets the state of Global Actions.
Disable the global actions to get key events.
- Parameters:
enable (bool) – Determines whether to enable or disable global actions.
- classmethod get()#
Get singleton when dialog is implemented as a subclass
Used by associated Button/SpriteActions.
- getMousePosition()#
Returns the mouse position.
- getRelativeMousePosition()#
Returns the mouse position relative to this widget.
- hide()#
Hides the widget.
- positionUnder(relativeTo, checkWasMoved=True, xoffset=0)#
Positions the dialog under or over the relataveTo widget.
- Parameters:
relativeTo (Widget) – The widget to position relative to.
checkWasMoved (bool) – Determines whether to check if widget is moved or not.
xoffset (int) – The offset value for the widget for x-axis.
- resize(width, height)#
Resize width/height of dialog.
This does not prevent the user from manually resizing like setting the width/height does.
- saveAsPng(fname)#
Saves the widget as a .png file.
- Parameters:
fname (str) – The file name for the .png
- Returns:
True if it was saved succesfully, False otherwise.
- Return type:
bool
- setF1HelpTopic(helptopic)#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- setProperties(kwds)#
Internal method called from constructors.
- show()#
Shows the widget.
- unitManager()#
(hwx.common.Units) Unit manager used to format floats with units
- property active#
Returns True if it is visible and enabled, False otherwise. (readonly property)
- property advancedTooltip#
The advanced tooltip that appears while hovering mouse over widget.
The text displayed in the titlebar.
- property children#
All widgets immediately contained by this one.
- property command#
Method called when the widget is activated or changed.
- property descendents#
All the widgets ultimately contained by this one.
- property docked#
Docks/Undocks the window and returns if the window is docked.
- property enabled#
The availability of the widget.
Disabled widgets are greyed out and don’t respond to input events.
- property font#
The font used in this widget (set with font or dict).
- property height#
Fixed height of the widget.
- property helpTopic#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- property layout#
Layout for the content area of the dialog.
Children widgets get added here.
- property maximumHeight#
The maximum allowable height inside the Layout.
- property maximumWidth#
The maximum allowable width inside the Layout.
- property minimumHeight#
The smallest allowable height inside the Layout.
- property minimumWidth#
The smallest allowable width inside the Layout.
- property name#
The unique identifier within a container.
- property parent#
The container that owns this widget.
- property position#
The location within the main window.
- property size#
The fixed size of the widget (width, height).
- property title#
The text displayed in the titlebar.
- property tooltip#
The tooltip that appears while hovering mouse over widget.
- property value#
The value of the widget.
- property visible#
The visibility of the dialog.
- property width#
The fixed width of the widget.
If a string or list of strings are specified, the width will be calculated from the longest string given the font.
MessageDialog Class#
- class MessageDialog(*args: Any, **kwargs: Any)#
A popup message dialog.
Used to display messages to the user. It may contain upto three buttons.
from hwx import gui def buttonClickCommand(buttonId): if buttonId == 0: gui.tellUser("Accept button clicked.") else: gui.tellUser("Reject button clicked.") msg = gui.MessageDialog(message="This is an example for message dialog", icon="info", button1="Accept", button2="Reject", command=buttonClickCommand) btn = gui.PushButton("Click Me!", command=lambda: msg.show()) show(btn)
- addChildren(children)#
Add child widgets/layouts into this widget.
Widget children get layed out using a VBoxLayout.
Typically, you’ll pass the parent/children into the constructor instead of calling this function directly.
- Parameters:
children (list[Widget] | Layout) –
- destroy()#
Deletes this and all its children.
- enableGlobalActions(enable)#
Sets the state of Global Actions.
Disable the global actions to get key events.
- Parameters:
enable (bool) – Determines whether to enable or disable global actions.
- get(v)#
Returns the message text.
- getMousePosition()#
Returns the mouse position.
- getRelativeMousePosition()#
Returns the mouse position relative to this widget.
- hide()#
Hides the widget.
- saveAsPng(fname)#
Saves the widget as a .png file.
- Parameters:
fname (str) – The file name for the .png
- Returns:
True if it was saved succesfully, False otherwise.
- Return type:
bool
- set(v)#
Sets the specified message.
- Parameters:
v (str) – Message text to be displayed.
- setF1HelpTopic(helptopic)#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- setProperties(kwds)#
Internal method called from constructors.
- show()#
Shows the MessageDialog and pauses exection till one button is clicked.
- Returns:
The button clicked.
- Return type:
int
- unitManager()#
(hwx.common.Units) Unit manager used to format floats with units
- property active#
Returns True if it is visible and enabled, False otherwise. (readonly property)
- property advancedTooltip#
The advanced tooltip that appears while hovering mouse over widget.
- property children#
All widgets immediately contained by this one.
- property command#
Method called when the widget is activated or changed.
- property descendents#
All the widgets ultimately contained by this one.
- property enabled#
The availability of the widget.
Disabled widgets are greyed out and don’t respond to input events.
- property font#
The font used in this widget (set with font or dict).
- property height#
Fixed height of the widget.
- property helpTopic#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- property icon#
The type of icon to be displayed. Valid choices are:
“noicon”
“informationicon”
“information”
“info”
“warningicon”
“warning”
“warn”
“erroricon”
“error”
“criticalicon”
“critical”
“questionicon”
“question”
“?”
“checkicon”
“check”
“redquestionicon”
“redquestion”
“redcheckicon”
“redcheck”
- property layout#
The layout that contains this widget’s children.
- property maximumHeight#
The maximum allowable height inside the Layout.
- property maximumWidth#
The maximum allowable width inside the Layout.
- property message#
The text message to be displayed inside the dialog.
- property minimumHeight#
The smallest allowable height inside the Layout.
- property minimumWidth#
The smallest allowable width inside the Layout.
- property name#
The unique identifier within a container.
- property parent#
The container that owns this widget.
- property size#
The fixed size of the widget (width, height).
- property tooltip#
The tooltip that appears while hovering mouse over widget.
- property value#
The value of the widget.
- property visible#
The visibility of the widget.
- property width#
The fixed width of the widget.
If a string or list of strings are specified, the width will be calculated from the longest string given the font.
Frame Class#
- class Frame(*args: Any, **kwargs: Any)#
Generic Widget container.
Base class for VFrame, HFrame and GridFrame, IconLabel, CollapsibleFrame, ComboButtonsWidgetStack and RadioButtonsWithWidgets.
- addChildren(children)#
Add child widgets/layouts into this widget.
Widget children get layed out using a VBoxLayout.
Typically, you’ll pass the parent/children into the constructor instead of calling this function directly.
- Parameters:
children (list[Widget] | Layout) –
- destroy()#
Deletes this and all its children.
- enableGlobalActions(enable)#
Sets the state of Global Actions.
Disable the global actions to get key events.
- Parameters:
enable (bool) – Determines whether to enable or disable global actions.
- getMousePosition()#
Returns the mouse position.
- getRelativeMousePosition()#
Returns the mouse position relative to this widget.
- hide()#
Hides the widget.
- saveAsPng(fname)#
Saves the widget as a .png file.
- Parameters:
fname (str) – The file name for the .png
- Returns:
True if it was saved succesfully, False otherwise.
- Return type:
bool
- setF1HelpTopic(helptopic)#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- setProperties(kwds)#
Internal method called from constructors.
- show()#
Shows the widget.
- unitManager()#
(hwx.common.Units) Unit manager used to format floats with units
- property active#
Returns True if it is visible and enabled, False otherwise. (readonly property)
- property advancedTooltip#
The advanced tooltip that appears while hovering mouse over widget.
- property children#
All widgets immediately contained by this one.
- property command#
Method called when the widget is activated or changed.
- property descendents#
All the widgets ultimately contained by this one.
- property enabled#
The availability of the widget.
Disabled widgets are greyed out and don’t respond to input events.
- property font#
The font used in this widget (set with font or dict).
- property frameShape#
Returns frame shape from the frame style. Below are the valid frame shape: - NOFRAME - BOX - PANEL - WINPANEL - HLINE - VLINE - STYLEDPANEL
- property height#
Fixed height of the widget.
- property helpTopic#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- property layout#
The layout that contains this widget’s children.
- property maximumHeight#
The maximum allowable height inside the Layout.
- property maximumWidth#
The maximum allowable width inside the Layout.
- property minimumHeight#
The smallest allowable height inside the Layout.
- property minimumWidth#
The smallest allowable width inside the Layout.
- property name#
The unique identifier within a container.
- property parent#
The container that owns this widget.
- property size#
The fixed size of the widget (width, height).
- property tooltip#
The tooltip that appears while hovering mouse over widget.
- property value#
The value of the widget.
- property visible#
The visibility of the widget.
- property width#
The fixed width of the widget.
If a string or list of strings are specified, the width will be calculated from the longest string given the font.
HFrame Class#
- class HFrame(*args: Any, **kwargs: Any)#
A Frame with a HBoxLayout.
HFrame groups controls horizontally so they can be sized and/or decorated as one.
from hwx import gui def onVisible(event): label.visible = event.value def onEnabled(event): label.enabled = event.value visible = gui.CheckBox("Visible?", value=True, command=onVisible) enabled = gui.CheckBox("Enabled?", value=True, command=onEnabled) label = gui.Label("A Label") frame_label = gui.HFrame(label) horizontalframe = gui.HFrame(visible, enabled, label) show(horizontalframe)
- addChildren(children)#
Add child widgets/layouts into this widget.
Widget children get layed out using a VBoxLayout.
Typically, you’ll pass the parent/children into the constructor instead of calling this function directly.
- Parameters:
children (list[Widget] | Layout) –
- destroy()#
Deletes this and all its children.
- enableGlobalActions(enable)#
Sets the state of Global Actions.
Disable the global actions to get key events.
- Parameters:
enable (bool) – Determines whether to enable or disable global actions.
- getMousePosition()#
Returns the mouse position.
- getRelativeMousePosition()#
Returns the mouse position relative to this widget.
- hide()#
Hides the widget.
- saveAsPng(fname)#
Saves the widget as a .png file.
- Parameters:
fname (str) – The file name for the .png
- Returns:
True if it was saved succesfully, False otherwise.
- Return type:
bool
- setF1HelpTopic(helptopic)#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- setProperties(kwds)#
Internal method called from constructors.
- show()#
Shows the widget.
- unitManager()#
(hwx.common.Units) Unit manager used to format floats with units
- property active#
Returns True if it is visible and enabled, False otherwise. (readonly property)
- property advancedTooltip#
The advanced tooltip that appears while hovering mouse over widget.
- property children#
All widgets immediately contained by this one.
- property command#
Method called when the widget is activated or changed.
- property descendents#
All the widgets ultimately contained by this one.
- property enabled#
The availability of the widget.
Disabled widgets are greyed out and don’t respond to input events.
- property font#
The font used in this widget (set with font or dict).
- property frameShape#
Returns frame shape from the frame style. Below are the valid frame shape: - NOFRAME - BOX - PANEL - WINPANEL - HLINE - VLINE - STYLEDPANEL
- property height#
Fixed height of the widget.
- property helpTopic#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- property layout#
The layout that contains this widget’s children.
- property maximumHeight#
The maximum allowable height inside the Layout.
- property maximumWidth#
The maximum allowable width inside the Layout.
- property minimumHeight#
The smallest allowable height inside the Layout.
- property minimumWidth#
The smallest allowable width inside the Layout.
- property name#
The unique identifier within a container.
- property parent#
The container that owns this widget.
- property size#
The fixed size of the widget (width, height).
- property tooltip#
The tooltip that appears while hovering mouse over widget.
- property value#
The value of the widget.
- property visible#
The visibility of the widget.
- property width#
The fixed width of the widget.
If a string or list of strings are specified, the width will be calculated from the longest string given the font.
VFrame Class#
- class VFrame(*args: Any, **kwargs: Any)#
A Frame with a VBoxLayout.
VFrame groups controls vertically so they can be sized and/or decorated as one.
from hwx import gui # Create widgets and arrange them in a vertical frame container. # "<->" symbol inside a VFrame children denotes a blank space stretch in a # row. verticalframe = gui.VFrame( (gui.Label("A Label"), gui.CheckBox("A CheckBox")), (gui.Label("B Label"), gui.CheckBox("B CheckBox")), ("<->", gui.PushButton("A PushButton")) ) show(verticalframe)
- addChildren(children)#
Add child widgets/layouts into this widget.
Widget children get layed out using a VBoxLayout.
Typically, you’ll pass the parent/children into the constructor instead of calling this function directly.
- Parameters:
children (list[Widget] | Layout) –
- destroy()#
Deletes this and all its children.
- enableGlobalActions(enable)#
Sets the state of Global Actions.
Disable the global actions to get key events.
- Parameters:
enable (bool) – Determines whether to enable or disable global actions.
- getMousePosition()#
Returns the mouse position.
- getRelativeMousePosition()#
Returns the mouse position relative to this widget.
- hide()#
Hides the widget.
- saveAsPng(fname)#
Saves the widget as a .png file.
- Parameters:
fname (str) – The file name for the .png
- Returns:
True if it was saved succesfully, False otherwise.
- Return type:
bool
- setF1HelpTopic(helptopic)#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- setProperties(kwds)#
Internal method called from constructors.
- show()#
Shows the widget.
- unitManager()#
(hwx.common.Units) Unit manager used to format floats with units
- property active#
Returns True if it is visible and enabled, False otherwise. (readonly property)
- property advancedTooltip#
The advanced tooltip that appears while hovering mouse over widget.
- property children#
All widgets immediately contained by this one.
- property command#
Method called when the widget is activated or changed.
- property descendents#
All the widgets ultimately contained by this one.
- property enabled#
The availability of the widget.
Disabled widgets are greyed out and don’t respond to input events.
- property font#
The font used in this widget (set with font or dict).
- property frameShape#
Returns frame shape from the frame style. Below are the valid frame shape: - NOFRAME - BOX - PANEL - WINPANEL - HLINE - VLINE - STYLEDPANEL
- property height#
Fixed height of the widget.
- property helpTopic#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- property layout#
The layout that contains this widget’s children.
- property maximumHeight#
The maximum allowable height inside the Layout.
- property maximumWidth#
The maximum allowable width inside the Layout.
- property minimumHeight#
The smallest allowable height inside the Layout.
- property minimumWidth#
The smallest allowable width inside the Layout.
- property name#
The unique identifier within a container.
- property parent#
The container that owns this widget.
- property size#
The fixed size of the widget (width, height).
- property tooltip#
The tooltip that appears while hovering mouse over widget.
- property value#
The value of the widget.
- property visible#
The visibility of the widget.
- property width#
The fixed width of the widget.
If a string or list of strings are specified, the width will be calculated from the longest string given the font.
GridFrame Class#
- class GridFrame(*args: Any, **kwargs: Any)#
A Frame with a GridLayout.
GridFrame groups controls in a grid layout so they can be sized and/or decorated as one.
from hwx import gui grid_frame = gui.GridFrame( (gui.Label("Label 1"), gui.PushButton("Click me"), gui.LineEdit(1.0)), (gui.Label("Label 2"), gui.PushButton("Click me"), gui.LineEdit(2.0)), (gui.Label("Label 3"), gui.PushButton("Click me"), gui.LineEdit(3.0)), ) show(grid_frame)
- addChildren(children)#
Add child widgets/layouts into this widget.
Widget children get layed out using a VBoxLayout.
Typically, you’ll pass the parent/children into the constructor instead of calling this function directly.
- Parameters:
children (list[Widget] | Layout) –
- destroy()#
Deletes this and all its children.
- enableGlobalActions(enable)#
Sets the state of Global Actions.
Disable the global actions to get key events.
- Parameters:
enable (bool) – Determines whether to enable or disable global actions.
- getMousePosition()#
Returns the mouse position.
- getRelativeMousePosition()#
Returns the mouse position relative to this widget.
- hide()#
Hides the widget.
- saveAsPng(fname)#
Saves the widget as a .png file.
- Parameters:
fname (str) – The file name for the .png
- Returns:
True if it was saved succesfully, False otherwise.
- Return type:
bool
- setF1HelpTopic(helptopic)#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- setProperties(kwds)#
Internal method called from constructors.
- show()#
Shows the widget.
- unitManager()#
(hwx.common.Units) Unit manager used to format floats with units
- property active#
Returns True if it is visible and enabled, False otherwise. (readonly property)
- property advancedTooltip#
The advanced tooltip that appears while hovering mouse over widget.
- property children#
All widgets immediately contained by this one.
- property command#
Method called when the widget is activated or changed.
- property descendents#
All the widgets ultimately contained by this one.
- property enabled#
The availability of the widget.
Disabled widgets are greyed out and don’t respond to input events.
- property font#
The font used in this widget (set with font or dict).
- property frameShape#
Returns frame shape from the frame style. Below are the valid frame shape: - NOFRAME - BOX - PANEL - WINPANEL - HLINE - VLINE - STYLEDPANEL
- property height#
Fixed height of the widget.
- property helpTopic#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- property layout#
The layout that contains this widget’s children.
- property maximumHeight#
The maximum allowable height inside the Layout.
- property maximumWidth#
The maximum allowable width inside the Layout.
- property minimumHeight#
The smallest allowable height inside the Layout.
- property minimumWidth#
The smallest allowable width inside the Layout.
- property name#
The unique identifier within a container.
- property parent#
The container that owns this widget.
- property size#
The fixed size of the widget (width, height).
- property tooltip#
The tooltip that appears while hovering mouse over widget.
- property value#
The value of the widget.
- property visible#
The visibility of the widget.
- property width#
The fixed width of the widget.
If a string or list of strings are specified, the width will be calculated from the longest string given the font.
TabWidget Class#
- class TabWidget(*args: Any, **kwargs: Any)#
NoteBook with tabs.
A NoteBook presents multiple mutually exclusive panes of content in the same area. It includes a tabbed control area with ‘text’ and a content area.
from hwx import gui # This method is called whenever a new Tab is selected. def tabChanged(event): # Get the label for the current tab notebook = event.widget label = notebook.TabLabel(notebook.current) # Create NoteBook widget and populate it with some Tabs notebook = gui.NoteBook(flat=False, command=tabChanged, ) notebook.addTab(gui.LineEdit("First"), text="First") notebook.addTab(gui.LineEdit("Second"), text="Second") notebook.addTab(gui.LineEdit("Third"), text="Third") show(notebook)
- addChildren(children)#
Add child widgets/layouts into this widget.
Widget children get layed out using a VBoxLayout.
Typically, you’ll pass the parent/children into the constructor instead of calling this function directly.
- Parameters:
children (list[Widget] | Layout) –
- addTab(child, text='', icon=None)#
Inserts a new tab with the specified child.
- Parameters:
child (Widget) – The widget to be added to the tab.
text (str) – The text to be displayed on the tab.
icon (str) – The icon to be shown in the tab.
- destroy()#
Deletes this and all its children.
- enableGlobalActions(enable)#
Sets the state of Global Actions.
Disable the global actions to get key events.
- Parameters:
enable (bool) – Determines whether to enable or disable global actions.
- getMousePosition()#
Returns the mouse position.
- getRelativeMousePosition()#
Returns the mouse position relative to this widget.
- hide()#
Hides the widget.
- insertTab(child, text='', icon=None, index=-1)#
Inserts a new tab with the specified child.
- Parameters:
child (Widget) – The widget to be added to the tab.
text (str) – The text to be displayed on the tab.
icon (str) – The icon to be shown in the tab.
index (int) – The index where to insert the tab.
- saveAsPng(fname)#
Saves the widget as a .png file.
- Parameters:
fname (str) – The file name for the .png
- Returns:
True if it was saved succesfully, False otherwise.
- Return type:
bool
- setF1HelpTopic(helptopic)#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- setProperties(kwds)#
Internal method called from constructors.
- show()#
Shows the widget.
- unitManager()#
(hwx.common.Units) Unit manager used to format floats with units
- property active#
Returns True if it is visible and enabled, False otherwise. (readonly property)
- property advancedTooltip#
The advanced tooltip that appears while hovering mouse over widget.
- property children#
All widgets immediately contained by this one.
- property command#
The method called when a the tab changes.
- property current#
The current tab.
- property descendents#
All the widgets ultimately contained by this one.
- property enabled#
The availability of the widget.
Disabled widgets are greyed out and don’t respond to input events.
- property flat#
Gives the TabWidget a borderless appearance.
- property font#
The font used in this widget (set with font or dict).
- property height#
Fixed height of the widget.
- property helpTopic#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- property layout#
The layout that contains this widget’s children.
- property maximumHeight#
The maximum allowable height inside the Layout.
- property maximumWidth#
The maximum allowable width inside the Layout.
- property minimumHeight#
The smallest allowable height inside the Layout.
- property minimumWidth#
The smallest allowable width inside the Layout.
- property name#
The unique identifier within a container.
- property parent#
The container that owns this widget.
- property size#
The fixed size of the widget (width, height).
- property tooltip#
The tooltip that appears while hovering mouse over widget.
- property value#
The value of the widget.
- property visible#
The visibility of the widget.
- property width#
The fixed width of the widget.
If a string or list of strings are specified, the width will be calculated from the longest string given the font.
WidgetStack Class#
- class WidgetStack(*args: Any, **kwargs: Any)#
A WidgetStack is used to display one widget at a time, generally depending on conditions or actions of other widgets.
from hwx import gui # Create line edits and displays them based on the value of a radio box def onClick(event): field = line_edit1 if event.value == "First" else line_edit2 widgetStack.visibleWidget = field # A radio button acts as the action and determines which LineEdit widget # is in the forefront and which goes in the background. radio_button = gui.HRadioButtons('First Second', command=onClick) line_edit1 = gui.LineEdit("First") line_edit2 = gui.LineEdit("Second") # Create a widgetStack and add the two line_edits as widgets widgetStack = gui.WidgetStack(widgets=(line_edit1, line_edit2)) frame = gui.VFrame(radio_button, widgetStack) # Run the demo show(frame)
- addChildren(children)#
Add child widgets/layouts into this widget.
Widget children get layed out using a VBoxLayout.
Typically, you’ll pass the parent/children into the constructor instead of calling this function directly.
- Parameters:
children (list[Widget] | Layout) –
- destroy()#
Deletes this and all its children.
- enableGlobalActions(enable)#
Sets the state of Global Actions.
Disable the global actions to get key events.
- Parameters:
enable (bool) – Determines whether to enable or disable global actions.
- getMousePosition()#
Returns the mouse position.
- getRelativeMousePosition()#
Returns the mouse position relative to this widget.
- hide()#
Hides the widget.
- saveAsPng(fname)#
Saves the widget as a .png file.
- Parameters:
fname (str) – The file name for the .png
- Returns:
True if it was saved succesfully, False otherwise.
- Return type:
bool
- setF1HelpTopic(helptopic)#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- setProperties(kwds)#
Internal method called from constructors.
- show()#
Shows the widget.
- unitManager()#
(hwx.common.Units) Unit manager used to format floats with units
- property active#
Returns True if it is visible and enabled, False otherwise. (readonly property)
- property advancedTooltip#
The advanced tooltip that appears while hovering mouse over widget.
- property children#
All widgets immediately contained by this one.
- property command#
Method called when the widget is activated or changed.
- property descendents#
All the widgets ultimately contained by this one.
- property enabled#
The availability of the widget.
Disabled widgets are greyed out and don’t respond to input events.
- property font#
The font used in this widget (set with font or dict).
- property height#
Fixed height of the widget.
- property helpTopic#
Popup web-browser helps when the user hits F1 when over this.
- Parameters:
helptopic (str) – Topic name user needs help in.
- property layout#
The layout that contains this widget’s children.
- property maximumHeight#
The maximum allowable height inside the Layout.
- property maximumWidth#
The maximum allowable width inside the Layout.
- property minimumHeight#
The smallest allowable height inside the Layout.
- property minimumWidth#
The smallest allowable width inside the Layout.
- property name#
The unique identifier within a container.
- property parent#
The container that owns this widget.
- property size#
The fixed size of the widget (width, height).
- property tooltip#
The tooltip that appears while hovering mouse over widget.
- property value#
The value of the widget.
- property visible#
The visibility of the widget.
- property visibleWidget#
The visibility of the widget in WidgetStack.
- property widgets#
The list of stacked widgets.
- property width#
The fixed width of the widget.
If a string or list of strings are specified, the width will be calculated from the longest string given the font.