Simplest way of displaying items (like reporter plugin) in filter plugin?

Hello, I would like to add a functionality in my filter plugin to display items in the edit view, like a reporter plugin. Is this easily possible? Thanks!

When the filter dialog is opened, register for a drawing callback and remove it when the dialog is closed.

I’m sorry, I don’t understand what that means. Could you provide a short code sample? Python Scripting API Documentation — Python Scripting API 3.0.4 documentation

Ah! :man_facepalming: Of course. Thanks a lot!

One question, I’m not sure when to remove the callback. In which function do I do this?

The basic structure of the filter is settings, start (which is where I assume I add the callback), and filter.

Do I perform Glyphs.removeCallback() in filter?

You could remove the callback in the methods that are called when you hit the OK and Cancel button.

I’m afraid I can’t find documentation on which methods those buttons call.

Depends on how you implement the dialog. If you use the .xib/.nib, you find it in the action inspector when the button is selected.
For details, have a look at the “” file to see what the method does. you find the file in GlyphsSDK/ObjectWrapper/GlyphsApp/

I can’t find an action inspector in XCode, sorry.

In the file, I’m unable to find which method is called when Cancel or Apply are clicked.

You have the .xib file open? Then select the button. Make sure the right sidebar is visible.
Bildschirmfoto 2023-04-11 um 00.17.08

Hmm. I see what you mean, but for me, ok Dialog doesn’t show up:


The filter itself doesn’t include the Cancel/Ok buttons, as those are automatically added by Glyphs.

For context, this is all I see:

I should have had a better look at this, sorry.

The relevant part is all in objcC. So you can’t find it.

You need to overwrite

- (void)confirmDialog:(id)sender


- (void)cancelDialog:(id)sender

and make sure to call super in both of them. so your code could look something like this:

def confirmDialog_(self, sender):
	objc.super(___yourClassName___, self). confirmDialog_(sender)

def cancelDialog_(self, sender):
	objc.super(___yourClassName___, self). cancelDialog_(sender)

___yourClassName___ needs to be replaced with the name of your plugins class. Or try to use self.className() or self.__class__.__name__ (print both, of the two might have some extra stuff)

1 Like

Thanks. I’m afraid I didn’t quite manage to set it up correctly.

I did the following:

	# On dialog show
	def start(self):
		# Set focus to text field
		Glyphs.addCallback(self.draw_calculations, DRAWFOREGROUND)

	def draw_calculations(self, layer, info):
			import traceback

	def confirmDialog_(self, sender):
		objc.super(Inktrapeze, self).confirmDialog_(sender)

	def cancelDialog_(self, sender):
		objc.super(Inktrapeze, self).cancelDialog_(sender)

But for some reason, once I close the dialogue, the drawings still are there (so, in this case, once I close the filter, the layer’s bezierPath is still displayed as red). What am I missing?

What happens if you scroll or zoom after yuu closed the dialog?

Nothing, the foreground stays red (also if I type new glyphs), until I re-open Glyphs.

You should not put @objc.python_method on those callbacks. That hides it from the objectiveC run-time and thous the buttons are not triggering your methods.

That works! Thanks a lot for your patience and help.