Feature > globals().update()
Also see :
- Using a text editor
- Return dictionary name (enter inside the second set of parentheses)
Following is a script that does not use
globals().update(). When Feature > Add Functions > Dialog box was used to create this script, the " Return dictionary name " was left blank.# Opens a dialog, prints the integer that the user enters. # dialog begin from dialog import Dialog from dialog.entry import IntEntry Dlg0 = Dialog( "Enter an Integer, See it Printed" ) Entry1 = IntEntry( Dlg0, "int_name", label="Integer:", default=1 ) Dlg0.done() # dialog end print("Integer is", Dlg0.int_name)This next parametric does use
globals().update(). To get this example,ddwas entered as the " Return dictionary name ." Note thatddis entered inside the second set of parentheses ofglobals().update(dd).# Opens a dialog and prints the user's entries to that dialog. # dialog begin from dialog import Dialog from dialog.entry import IntEntry Dlg0 = Dialog( "Enter an Integer, See it Printed" ) Entry1 = IntEntry( Dlg0, "int_name", label="Integer:", default=1 ) dd = Dlg0.done() # creates a dictionary named dd # dialog end globals().update(dd) # dd is entered in parentheses print("Integer is", int_name)Since
globals().update(dd)is used in the second example, the integer that the user enters can be returned usingint_nameinstead ofDlg0.int_name. Ifint_namehad been used in the first example, that first script would have produced an error.