Skip to content

Instantly share code, notes, and snippets.

@okay-type
Last active May 4, 2020 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okay-type/e301a1da610bfdbe484787e93f52ef16 to your computer and use it in GitHub Desktop.
Save okay-type/e301a1da610bfdbe484787e93f52ef16 to your computer and use it in GitHub Desktop.
toggle font window toolbar in robofont
# menuTitle : Toggle Font Toolbar
# shortCut : command+alt+`
from mojo.UI import AllFontWindows
'''
toggle the visibility of the toolbar and the status bar in robofont's font overview window
sorry, i haven't tested this in single window mode or anything
'''
def toggleFontWindowToolbar():
# get first window state and use that for the other windows so they all stay in sync
w1 = AllFontWindows()[0].window().getNSWindow()
w1state = w1._toolbarIsShown()
for window in AllFontWindows():
if window is None:
return
w = window.window().getNSWindow()
(wX, wY), (wW, wH) = w.frame()
if w1state == 1:
w.hideToolbar_(True)
show = False
else:
w.showToolbar_(True)
show = True
w.setFrame_display_animate_(((wX, wY), (wW, wH)), True, False)
fo = window.fontOverview
fo.statusBar.show(show)
fo.views.selectionStatus.show(show)
fo.views.sizeSlider.show(show)
fo.getGlyphCollection().setPosSize((0, 0, 0, -20))
if show is False:
fo.getGlyphCollection().setPosSize((0, 0, 0, 0))
# the view mode buttons, there has to be a better way
vmb = fo.views.collectionSplitView.getSplitView().subviews()[1]
vmb.subviews()[1].vanillaWrapper().show(show)
vmb.subviews()[2].vanillaWrapper().show(show)
toggleFontWindowToolbar()
@okay-type
Copy link
Author

quick fix to make sure all windows have the same toolbar state

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment