Skip to content

Instantly share code, notes, and snippets.

@weiweihuanghuang
Created January 23, 2016 12:29
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 weiweihuanghuang/2480e1e021487a0e66db to your computer and use it in GitHub Desktop.
Save weiweihuanghuang/2480e1e021487a0e66db to your computer and use it in GitHub Desktop.
Show master in the Preview Field or Window
#MenuTitle: Show master
# -*- coding: utf-8 -*-
__doc__="""
Show the amster in preview field or preview window.
"""
import GlyphsApp
from Foundation import NSApplication
numberOfInstances = len( Glyphs.font.instances )
Doc = Glyphs.currentDocument
PreviewField = Doc.windowController().activeEditViewController()
PreviewPanel = None
for p in NSApplication.sharedApplication().delegate().valueForKey_("pluginInstances"):
if p.__class__.__name__ == "NSKVONotifying_GlyphsPreviewPanel":
PreviewPanel = p
try:
currentInstanceNumber = PreviewField.selectedInstance()
if currentInstanceNumber < numberOfInstances:
PreviewField.setSelectedInstance_( 0 )
if PreviewPanel:
PreviewPanel.setSelectedInstance_( 0 )
else:
PreviewField.setSelectedInstance_( 0 )
if PreviewPanel:
PreviewPanel.setSelectedInstance_( 0 )
except Exception, e:
print "Error:", e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment