//Edit: This post is not relevant anymore – see further comments
Hi @tamirhassan,
If I understand correctly:
you want to edit your plugin’s UI elements everytime you open the export dialogue.
I have quick hacky solution, with pyobjc objects, which will help you achieve that.
I think, I could also later try to work on solution where you would be able to create your own NSView with vanilla objects instead of creating xib / nib files.
In the attachment you will find the template with some additional example code in plugin.py file, that allows you to call some custom stuff when the dialog is being opened.
Let me go into the details:
For this example, I added new text line to the original template’s xib file (“Family Name:”).
This TextField will be used to display current font.familyName
attribute.

I added following lines to the original code:
<on line 22>
import AppKit
that is straight forward import of objc AppKit
<on lines 29 to 44>
class ExportWindowDelegate(AppKit.NSObject):
def initWithFormatPluginObject_(self, object):
self.plugin = object
return self
def windowDidBecomeKey_(self, event):
# looking for the NSView that we created with xib file
# in the topLevelObjects attribute
for obj in self.plugin.topLevelObjects:
if isinstance(obj, AppKit.NSView):
# iterating through the elements of this NSView
# (in this example I'm looking for NSTextFields with title )
for sub_obj in obj.subviews():
if isinstance(sub_obj, AppKit.NSTextField):
if sub_obj.stringValue().startswith("Family Name: "):
sub_obj.setStringValue_("Family Name: {}".format(Glyphs.font.familyName))
This is the most important part of the edits that I’ve made.
This is delegate that I’m later setting for exportDialog, which will allow you to do stuff, whenever this dialog will be opened.
Your code should go into the windowDidBecomeKey_
method, preferably after for sub_obj in obj.subviews():
– this is where all the edits of UI elements take place.
In my case, I looked for TextField object, which string value starts with "Family Name: " and adding current family name to it (lines 43, 44).
<on lines 60 to 62>
exportWindow = Glyphs.delegate().exportWindow()
self.windowDelegate = ExportWindowDelegate.alloc().initWithFormatPluginObject_(self)
exportWindow.setDelegate_(self.windowDelegate)
- line 60 – im defining variable, that will contain exportWindow obj (I’m stealing it from Glyphs’ delegate object)
- line 61 – I’m initialising
ExportWindowDelegate
object by passing PluginClassName
to it. Thanks to this passing, we are able to iterate through the UI elements in the ExportWindowDelegate
class
- line 62 – I’m linking
ExportWindowDelegate
to exportWindow
as a delegate
Hope that helps.
If you have any questions, feel free to ask them.
Here is this example:
PluginTest.glyphsFileFormat.zip (89.6 KB)