Prompt(float)

  • When the script is an ok-cancel dialog opens with a prompt to enter a decimal number.
  • When the user who runs the script presses " OK " on the ok-cancel dialog, the value that in entered to the dialog becomes a variable (var is the following example) that is presumably used later in the script.

Also see :

Quick Notes

Example :

The Prompt() function in this example defines a float prompt because the first argument -- 14.25 -- is a floating point number . Pressing " OK " on the dialog returns the floating point equivalent to the numerical value that is entered, even if the user enters an integer . Pressing " Cancel " returns ResponseNotOK .

# Converts decimal inches to ft-in frac and millimeters.
from param import Prompt, ResponseNotOK, Units, dim_print
Units("feet")                     # sets dim_print output to ft-in frac
try:
    inches = Prompt(14.25, "Enter decimal inches:")
    mm = inches * 25.4
    print("The value (inches) you entered =", inches)
    print("The value in ft-in frac =", dim_print(inches))
    print("The value in millimeters =", mm)
except ResponseNotOK:                # user presses "Cancel"
    pass