Simple Dialog

Simple Dialog
 1# Simple function to prompt the user for two distance values
 2
 3
 4# Set the default values, show the dialog, then use the entered values
 5Lsize = 100
 6Wsize = 200
 7
 8# Simple function to prompt the user for two distance values
 9def show_values(l, w):
10    the_dialog = impact.gui.make_dialog("Rectangle")
11
12    # the distance entry fields
13    field_length = the_dialog.fields.add_distance(l, "Length", False)
14    field_width = the_dialog.fields.add_distance(w, "Width", False)
15
16    # the buttons
17    the_dialog.add_button(ipDialogButtonType.dbtOk)
18    the_dialog.add_button(ipDialogButtonType.dbtClose)
19
20    # show the dialog and determine which button was pressed
21    the_button = the_dialog.show_modal(None)
22    if the_button==ipDialogButtonType.dbtOk:
23
24        # retrieve the values
25        l = field_length.value
26        w = field_width.value
27        show_values=True
28    else:
29        show_values=False
30
31if show_values(Lsize, Wsize):
32    if Lsize>0 and Wsize>0:
33        impact.gui.output_toolbox.add("Create rectangle, size " + str(Lsize) + " by " + str(Wsize))