The example script below shows how to add a custom button to the toolbar of the Font Overview by subscribing to the fontWindowWillShowToolbarItems notification.

The gear icon is selected from macOS system icons using NSImageName.

from AppKit import NSImageNameAdvanced
from mojo.events import addObserver

class AddToolbarItem:

    def __init__(self):
        addObserver(self, 'addToolbarButton', 'fontWindowWillShowToolbarItems')

    def addToolbarButton(self, notification):
        # create the button
        newItem = dict(
            itemIdentifier='MyButton',
            label='My Button',
            toolTip='My Button',
            imageNamed=NSImageNameAdvanced,
            callback=self.customButton)     
        # add it to the toolbar
        notification['toolbarItems'].insert(2, newItem)

    def customButton(self, sender):
        print('click!')

AddToolbarItem()

addToolbarItem problem (RoboFont Forum)

Last edited on 14/01/2020