Custom inspector in single window mode



  • Is there a simple way to replace the default inspector with my own in single window mode?
    Or alternatively add and remove sections from it's accordion view?


  • admin

    He Timo

    This example adds an extra pane in the inspector window and extra toolbar icons in a glyph window and font collection window. This also works in single window mode.

    from mojo.events import addObserver
    
    from vanilla import *
    
    class Test(object):
    
        def __init__(self):
            # subscribe to the moment when an inspector will be shown
            addObserver(self, "inspectorWindowWillShowDescriptions", "inspectorWindowWillShowDescriptions")
            # subscribe to the moment when a glyph windwo will be shown
            addObserver(self, "glyphWindowWillShowToolbarItems", "glyphWindowWillShowToolbarItems")
            # subscribe to the moment when a font windwo will be shown
            addObserver(self, "fontWindowWillShowToolbarItems", "fontWindowWillShowToolbarItems")
    
            # keep a reference of the inserted inspector view
            self.editor = TextEditor((10, 10, -10, -0))
    
        def inspectorWindowWillShowDescriptions(self, notification):
            # create an inspector item
            item = dict(label="My Custom View", view=self.editor)
            # this is just a list object where you can append and insert
            notification["descriptions"].insert(0, item)
    
        def glyphWindowWillShowToolbarItems(self, notification):
            # create an toolbar item
            item = dict(itemIdentifier="customGlyphToolbar", label="Do It", callback=self.doIt, imageNamed="toolbarRun")
            notification["toolbarItems"].insert(-2, item)
    
        def fontWindowWillShowToolbarItems(self, notification):
            # create an toolbar item
            item = dict(itemIdentifier="customFontToolbar", label="Do It", callback=self.doIt, imageNamed="toolbarRun")
            notification["toolbarItems"].insert(2, item)
    
        def doIt(self, sender):
            print("do it")
    
    Test()
    


  • Super! Thanks Frederik!



Looks like your connection to RoboFont ● Forum was lost, please wait while we try to reconnect.