Skip to content

Instantly share code, notes, and snippets.

@mekkablue
Last active August 29, 2015 14:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mekkablue/11042782 to your computer and use it in GitHub Desktop.
Save mekkablue/11042782 to your computer and use it in GitHub Desktop.
Grid Switcher for Glyphs.app
#MenuTitle: Grid Switcher
# -*- coding: utf-8 -*-
"""Turns Grid on and off."""
import vanilla
import GlyphsApp
class GridOnOff( object ):
def __init__( self ):
currentGridStep = Glyphs.font.gridMain()
self.w = vanilla.FloatingWindow( (170, 80), "Grid Switcher", autosaveName="com.mekkablue.GridOnOff.mainwindow" )
self.w.currentGridStep = vanilla.TextBox( (15, 12+2, -15, 22), "Current Grid Step: %i" % currentGridStep, sizeStyle='regular' )
self.w.switchButton = vanilla.Button((15, -22-15, -15, -15), "Switch Grid", sizeStyle='regular', callback=self.GridOnOffMain )
self.w.setDefaultButton( self.w.switchButton )
self.w.center()
self.w.open()
def GridOnOffMain( self, sender ):
try:
gridStep = Glyphs.font.gridMain()
if gridStep != 0:
newGridStep = 0
else:
newGridStep = 1
Glyphs.font.setGridMain_( newGridStep )
self.w.currentGridStep.set( "Current Grid Step: %i" % newGridStep )
except Exception, e:
raise e
GridOnOff()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment