Interacting with the user

Ask a user to enter a string with the ask() function

def hello(n):
    message("Hello, %s!" % n)
def fail():
    alert("The operator refuses to respond!")
ask("What is your name?", hello, fail)
ask("What is your name?", hello, fail, 60, "Vasily") 

Upon completion the dialog will call one of the function. The first one should have a parameter which contains a response to the question. The other one will be called if the "Cancel" button or Esc is pressed. The timeout period, after which the window will be closed, can be specified in seconds. You can also specify the initial string.

Ask to select one of several options using the question () function

def yes(): message(1)
def no(): message(2)
def dont_know(): message(3)
def other(): message(4)
question("Have you been drinking cognac in the mornings for a long time?",
    "Yes", yes,
    "No", no,
    "I don't know", dont_know,
    "Other", other,
    60) 

There should be several buttons in the response. The first button is a default one, which is selected by pressing "Enter". You can specify the timeout period, after which the first option will be selected.

Tip

You can see more extended example of a dialog with the user in the tov_general script, by uploading it to the built-in script editor.