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 _result = None
11 the_dialog = impact.gui.make_dialog("Rectangle")
12
13 # the distance entry fields
14 field_length = the_dialog.fields.add_distance(l, "Length", False)
15 field_width = the_dialog.fields.add_distance(w, "Width", False)
16
17 # the buttons
18 the_dialog.add_button(ipDialogButtonType.dbtOk)
19 the_dialog.add_button(ipDialogButtonType.dbtClose)
20
21 # show the dialog and determine which button was pressed
22 the_button = the_dialog.show_modal(None)
23 if the_button==ipDialogButtonType.dbtOk:
24
25 # retrieve the values
26 l = field_length.value
27 w = field_width.value
28 _result = True
29 else:
30 _result = False
31 return _result
32
33if show_values(lsize, wsize):
34 if lsize>0 and wsize>0:
35 impact.gui.output_toolbox.add("Create rectangle, size " + str(lsize) + " by " + str(wsize))