Dialog (hwx.gui)#

class Dialog(parent='MainWindow', name='', children=None, **kwds)#

Bases: DialogBase

A top-level window mostly used for short-term tasks and brief communications with the user.

Attribute Table#

Name

Type

closeOnEscape

property

Method Table#

Name

Description

accept (self, returnValue)

Close the dialog and returnValue from exec.

exec (self)

Show as a model dialog, blocking code execution until it is closed.

reject (self)

Syntactic sugar to close the exec dialog without accepting a value.

show (self)

Shows the dialog and continues with script execution.

Example

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 not modal dialog 
# dialog.show()
show(dialog)
show()#

Shows the dialog and continues with script execution.

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.

accept(returnValue)#

Close the dialog and returnValue from exec.

reject()#

Syntactic sugar to close the exec dialog without accepting a value. None is returned from exec.

property closeOnEscape: bool#

The behavior when the user presses the Esc key in a dialog.