Prompt user for input

I’ve been exploring the scripting capabilities of Glyphs for a while now, and it’s very, very impressive… thanks for making it such a priority.

One feature I’m really missing from Python (not sure if it’s currently possible - I haven’t found a way so far) is the ability to have a script prompt the user for input.

In regular Python, typing someValue = input('enter value: ') would allow you to set a variable at runtime without changing the script, however it causes an error if done through Glyphs (which I suppose makes sense since there’s no interactive console).

Right now, if I run a script with parameters specific to the current font I’m working on (or I want to test some different values), I have to open the script’s folder, open the script in an editor, and change variables from their default values, save, and run the script (or paste the whole thing into the macro panel, which can be just as tedious). The next time I run the script, I may want to use the initial values, but now they’re different and I have to repeat the process to change them back.

Is there a way to accept user input that I just haven’t discovered?

Try Vanilla. You can find installation instructions and lots of usage examples in my GitHub repository:

Thanks, mekkablue. I’ve installed it, and my scripts can now access user input from a window’s text field, but, as in your examples, it’s through the use of a callback to another function.

Is there a simple way to run a window modally (halting execution of the script until user input), as per Python’s input() function?

You can use this:
from robofab.interface.all.dialogs import AskString
value = AskString(“Ask something:”)

Georg Seifert
Wow - that’s exactly what I was looking for. Thanks so much Georg!