Basic GUI for Scripting

Is there a resource for building a very simple GUI for own written scripts out there? Your Tutorials are amazingly great, Mekkablue. I checked the docu.glyphsapp, and try to read myself through your scripts on GitHub, but they are so complex, that I find it hard to understand what the basics are to build my own.

Do i have to dig myself into Vanilla for this?

Let’s say for example I have this script:

#MenuTitle: Open Tab with String
’’’ Opens a Tab with the String typed here ‘’'
Glyphs.currentDocument.windowController().addTabWithString_( “onnonnoon” )

So if i want to have a GUI that asks me for the desired string, where can I get information about that?

BTW: how can i call a certain Glyph (e.g. \omicron \kappa …)? I guess i cannot work with »string« then?

Thanks so much in advance!

  1. Vanilla is as easy as it gets. You will have to deal a little bit with objects in Python, I am afraid. Feel free to dig through my Vanilla scripts, and steal the GUI of a script where the window would fit your purposes.

  2. Try this:
    Glyphs.font.glyphs[“omicron”]

1 Like

motivating enough, i will try & do so. thank you

You can try this:
Glyphs.currentDocument.windowController().addTabWithString_( “/omicron” )

great, thanks.

and i found a little bug, i guess. when i run this script, it opens the tab, but doesn’t show the actual tab on top. when i open the regular way (cmt-t or double clicking existing letters) it is there, though.

see here:
http://postimg.org/image/4yoy63su3/

only happens, when there was no tab open so far. but if it does, you also can not come back to the font overview f.i.

(newest beta on OS 10.6.8)

okay, so i got the interface running like a charm with vanilla. puzzled my way through your scripts, mekkablue.

one thing i had trouble with: i had a
print yes
in the Callback for the button (right, i forgot the “”) for checking my script. It did not work, but also did not give me an error in the output.

after putting the string yes in quotes, everything worked

when i only have a
print yes
in a script and nothing else, i get the error message as expected, though

The exception (=error) is probably caught by a try/except statement.

It should be
return True

didn’t want the true or false, just a debugging output during the steps developing the script. like print “this loop is running” or so :slight_smile: