Some SDK-related questions

What is the benefit of renaming PluginClassName?

Why is there example code in the templates? The .glyphsReporter template draws a blue rectangle by default. My understanding was that there is a distinction between samples and templates.

Which of the code or the the methods can or do I have to I remove (like the blue rectangle)?

Couldn’t the whole SDK thing be handled much more cleanly and elegantly by working with a user-defined derived class instead of messing around with the template code (OOP FTW!)? What if the template gets updated? Am I supposed to use a diff tool and work my way though the code?

How can a .glyphsReporter plugin find out whether the Text Tool or the Select Tool is active?

I think it circumvents namespace problems, but I am not sure that is still an issue.

The idea was to facilitate coding for people less experienced in Python scripting. That is why all the read-mes are more like a step-by-step guide. But see below.

We are in the process of discussing exactly that. I will contact you in a DM about it.

Since I made a bunch of reporter plugins I can exactly see Tim’s points. Many of these things are not so important to me anymore, because I got used to them and removing, renaming, etc got quite a habit. But keeping track of the published versions, the version on different computers plus the actual template being updated once in a while also breaks my head sometimes.

If you are interested in more (user/developer) input about the reporter plugins, I’d love to join the discussion. :slight_smile:


there is


as well as lastSelectToolIndex but these might not be 100% bulletproof when someone adds his own items to the toolbar. And you might need to initialise Glyphs first with sth like this Glyphs = NSApplication.sharedApplication()

Thanks, Mark! This helped. So there are features that are practically impossible to know through the “official” channels (i.e.

Rainer: Good to know. I’ll be happy to help.

You’re welcome, Tim. It is always good to check the Core as well: and very very often I print out the help() for every bits and pieces. There you find probably the most stuff.

Not every method should be documented on But you can:

  1. look into header files inside the app;
  2. query objects in Python, see below.

E.g. this is what I have in my Macro window:

searchterm = "tool"
myObj = GSWindowController

for x in dir(myObj):
	if searchterm.lower() in x.lower():
		print x

print myObj
1 Like

Rainer, that is so great! I just made a script from that. With an UI to ask you for your search term. Will update to pass more objects.

Haha, I have been thinking about such a script too, but I have always kept it in my Macro Window. Actually I keep this here in the window, too. Right above the snippet I pasted in the previous post.

#myObj = GSLayer
#myObj = thisLayer.color()
#myObj = GSComponent # thisLayer.components[0].transformStruct()
#myObj = GSPath #Glyphs
#myObj = GSFontMaster
#myObj = GSGlyphsInfo
#myObj = GSGlyph
#myObj = smartComp.partsSettings()
#myObj = NSClassFromString("GlyphsFilterRoundCorner")

… and so on… I uncomment as needed.

Idea: I wonder whether the script should have another EditText for the object you are querying, and you turn the string you receive into a class with NSClassFromString(myObjString)…?

Haha, I just updated in the meantime to ask for the object to search in as well.

Ok, now I got it. Maybe I could add a dropdown with a bunch of objects, and one “custom” later.

Hint hint. Look at my insert instances script. You can do both at the same time.

This is not a good idea. Use:

# and

This gives you the instance of the current tool. The distinction is important e.g. for the measurement tool. The main drawing stuff will be handled either by the select tool or the text tool (the drawDelegate) and the user input will be handled by the measurement tool (the eventDelegate).

@mekkablue Right, I always oversaw this ComboBox. Updated the script already.

@GeorgSeifert Good to know, looks good. It felt kind of hacky to use the index. Thanks Georg! With this script, hopefully I’ll make fewer mistakes soon :slight_smile:

and an example on how to use it:

if (Glyphs.currentDocument.windowController().toolDrawDelegate().isKindOfClass_(NSClassFromString("GlyphsToolText")):
    # do things for text tool


if (Font.parent.windowController().toolDrawDelegate().isKindOfClass_(NSClassFromString("GlyphsToolSelect")):
    # do things for selection tool


if (Font.parent.windowController().toolDrawDelegate().isKindOfClass_(NSClassFromString("GSToolSelect")):
    # do things for all tools that are subclasses of GSToolSelect (most path editing tools) 

to catch even more, use GlyphsPathPlugin, it’s the super class of GSToolSelect

Mark and Rainer: Thanks for that!

Somehow, I prefer to have a list of all methods (as a simple text file) and then search it using my text editor. Seems more convenient and powerful than a custom tool for the search. (Related: My philosophy is “Sorting is always more powerful than filtering” but we have had that discussion before.)

Just tried to switch off the background via Python. This is how far I got:


Throws an error, it seems I need to pass an object that has a state method or attribute? How to create it?


That is just the IBAction, the argument is the sender. What do you want to do? Same thing as View > Show Background?

Yes, I am trying to do the same as View > Show Background via Python.

All the questions I asked in this thread arose while trying to achieve the seemingly simple task of changing the background layer color (which Glyphs does not allow to set, for reasons unknown). So I wrote this plugin (which seems a little complicated for this task). Naturally, the plugin should deactivate the built-in background, otherwise we get this gray line on top of the orange one:

Any ideas how to achieve this (line 105 is my previous attempt, which did not work)?

Try this:

Glyphs.defaults["showBackground"] = 0

Excellent, this works! Thanks a lot.

Is there a way to find a list of all the keys I can use for Glyphs.defaults (or, in fact, the keys currently in Glyphs.defaults)? I cannot iterate over it.