Stop a Python program until a user completes an action

My original program used input, for example:

n = input("Enter your favorite number: ")
# do stuff with number

Now I’ve switched to GTK GUI, but still want everything to be done. Now let's look at this very similar piece of code:

n = myWindow.getNumber()
# do stuff with number

Is it possible to write a method getNumber()that returns only after the user clicks the submit button in the window? (for example, how the function works input), or this is my only option:

def callback(widget, event):
    n = myWindow.inputWidget.getValue()
    # do stuff with number

n = myWindow.getNumber(callback)

Update: I am looking to do this without gtk.Dialog, since I do not want the dialog to appear every time user input is required.

+5
source share
1 answer

. GTK ( PyGTK), .

+3

All Articles