Where does the Python file go in a Glyphs Plugin?

I’ve managed to follow the tutorials Writing plug-ins | Glyphs and looked a bit into GlyphsSDK/Python Templates/Filter/dialog with xib at Glyphs3 · schriftgestalt/GlyphsSDK · GitHub
I have a filter that opens a dialog, and the first thing I tried to do was just to get a debug-log to print somewhere when I click on the OK-button of the filter. The regular NSLog doesn’t seem to do anything, but perhaps a python print-statement might.

I see some plugins have a separate python files, like the shadow plugin (does it have something to do with vanilla-cocoa or is it just a regular interface-builder plugin with an external python script?), but most plugins only have the .nib-file that I assume is compiled code.

I’m not entirely sure on how the Objective C and Python code interacts here. Is it possible to have an external Python file and call methods in the plugin, or do I just use the @objc.python_method-annotation within the Objective C (.m) file and then write plain python in there?

Is it possible to add an external Python file in the XCode project somewhere and it’ll automatically end up in the finished plugin when I compile like with the shadow filter, should I just stick to the inline @objc.python_method-annotation or is there some other “standard practice” of interacting with the Glyphs API?


You need to decide if you like to build the plugin in python or objectiveC. When you have python code that contains the logic for the plugin, use a python plugin. You can copy the template and replace all places where you find four underscores (____). Or use the PluginMaker tool. Xcode is then only used to edit the .xib file. The readme explains that in detail.
You can add more python files into the Resource folder.

took me some time to get my head around that. If I use Xcode, it looks like I need both a .xib and a .nib file, the xib is fairly easy to understand since it’s basically just xml, but the nib is a binary, so I guess even with Python in that case I would need a .m and .h file in the project and compile that to a .nib? Does that mean I have an empty plugin implementation in the obj-c file or no obj-c file (.m and .h) at all in the case of combining xib/nib with Python?

The question I have for the Xcode approach with Obj-C (no python), is there a way to get debug logging similar to how I can make print statements in python? It looks like NSLog doesn’t have an easily accessible console to get print-statements like I can do with the macro panel.

And what is the PluginMaker tool? I couldn’t see anything about it in the SDK or the different schriftgestalt repos.

Compiling the nib is explained, among pretty much everything else, in this tutorial: Writing plug-ins | Glyphs

Otherwise, Florian made a very comprehensive tutorial on how to get started writing a plugin in XCode using Swift: Creating a Glyphs Plugin in Swift - YouTube

No.

The .nib is a binary representation of the user interface. The .h/.m files are the source files for the app logic. The two things are not connected. You can use .nib files from .m files but also from .py files.

1 Like