Prompt(int)

  • When the script is Run an ok-cancel dialog opens with a prompt to enter an integer (a counting 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

Examples :

# Raises 2 to the power the user enters and prints the result.
from param import Prompt, ResponseNotOK
try:
    power = Prompt(2, "Power to raise 2 to:")
    result = 2 ** power
    print("You have raised 2 to the power of", power)
    print("The result is", result)
except ResponseNotOK:
    print("You pressed the Cancel button.")

# Converts a distance entered in millimeters to inches.
from param import Prompt, ResponseNotOK
try:
    mm = Prompt(100, "Enter a number of millimeters:")
    inches = mm / 25.4
    print("The number of mm you entered =", mm)
    print("This number converted to inches =", inches)
except ResponseNotOK:
    pass