MicroDialog (hwx.gui)#

class MicroDialog(parent='CentralWidget', name='', children=None, **kwds)#

Bases: Container

A light-weight dialog residing inside the graphics area that typically contains entry fields and buttons that have an immediate effect.

Attribute Table#

Name

Type

margin

property

position

property

spacing

property

visible

property

Method Table#

Name

Description

addChildren (self, children)

Add child widgets/layouts into this widget.

Example

from hwx import gui

def onYClick(): yField.value = 1; xField.value = zField.value = 0.0

def onZClick(): zField.value = 1; yField.value = xField.value = 0.0

def onXClick(): xField.value = 1; yField.value = zField.value = 0.0

def onActiveClick():
reverse.enabled = not reverse.enabled
gravity.enabled = not gravity.enabled

def plusMinusClick():
gravity.value *= -1.0

# - widgets ----------------------------------------------------------------
# first row
active = gui.PushButton(icon='microEditStrip-18.png',
command=onActiveClick, )

reverse = gui.PushButton(icon='microReverseMagnitudeStrip-18.png',
tooltip="Reverse Direction of the Magnitude", command=plusMinusClick, )
gravity = gui.DoubleEdit(9810)

# second row
xHButton = gui.PushButton(icon='microCoordinateGlobalXStrip-18.png',
command=onXClick)
yHButton = gui.PushButton(icon='microCoordinateGlobalYStrip-18.png',
command=onYClick)
zHButton = gui.PushButton(icon='microCoordinateGlobalZStrip-18.png',
command=onZClick)

xyzHButtons = gui.HFrame(xHButton, yHButton, zHButton)

expander = gui.ExpanderButton()

xVButton = gui.PushButton(icon='microCoordinateGlobalXStrip-18.png',
command=onXClick)
yVButton = gui.PushButton(icon='microCoordinateGlobalYStrip-18.png',
command=onYClick)
zVButton = gui.PushButton(icon='microCoordinateGlobalZStrip-18.png',
command=onZClick)

xField = gui.DoubleEdit(1)
yField = gui.DoubleEdit(0)
zField = gui.DoubleEdit(0)

def moveToPos(x, y): microDialog.position = (x, y)

pos1 = gui.PushButton("POS1", command=lambda: moveToPos(0, 0))
pos2 = gui.PushButton("POS2", command=lambda: moveToPos(50, 50))
pos3 = gui.PushButton("POS3", command=lambda: moveToPos(100, 0))
positions = (pos1, pos2, pos3)

# t3-5 rows
microDialog = gui.MicroDialog(
children=gui.ExpanderLayout((active, reverse, gravity, "-"),
   (None, None, xyzHButtons, expander), (xVButton, xField, "-", "-"),
   (yVButton, yField, "-", "-"), (zVButton, zField, "-", "-"),
   (positions, "-", "-", "-"), ))

show(microDialog)
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) –

property visible#

The dialog visibility.

property position#

The location within the main window.

property margin#

The spacing around the sides of the microdialog.

property spacing#

The spacing between items inside the microdialog.

A tuple with horizontal and vertical spacing can be provided for microdialogs that use grid layouts.