Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3 #11

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions LabelKey.glyphsPalette/Contents/Info.plist
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDisplayName</key>
<string>Label Key</string>
<string>en</string>
<key>CFBundleExecutable</key>
<string>plugin</string>
<key>CFBundleIdentifier</key>
Expand All @@ -14,12 +12,10 @@
<string>6.0</string>
<key>CFBundleName</key>
<string>Label Key</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleVersion</key>
<string>2.0</string>
<key>CFBundleShortVersionString</key>
<string>2.0</string>
<key>CFBundleVersion</key>
<string>3</string>
<key>UpdateFeedURL</key>
<string>https://github.com/RobertPratley/labelKey/LabelKey.glyphsPalette/Contents/Info.plist</string>
<key>productPageURL</key>
Expand All @@ -30,9 +26,5 @@
<string>Copyright, RobertPratley, 2017</string>
<key>NSPrincipalClass</key>
<string>labelKey</string>
<key>PyMainFileNames</key>
<array>
<string>../MacOS/main.py</string>
</array>
</dict>
</plist>
11 changes: 0 additions & 11 deletions LabelKey.glyphsPalette/Contents/MacOS/main.py

This file was deleted.

Binary file modified LabelKey.glyphsPalette/Contents/MacOS/plugin
100644 → 100755
Binary file not shown.
1 change: 0 additions & 1 deletion LabelKey.glyphsPalette/Contents/PkgInfo

This file was deleted.

19 changes: 13 additions & 6 deletions LabelKey.glyphsPalette/Contents/Resources/plugin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8
from __future__ import division, print_function, unicode_literals

###########################################################################################################
#
Expand All @@ -11,6 +12,7 @@
#
###########################################################################################################
from vanilla import *
import objc
import re
import os
import codecs
Expand All @@ -19,8 +21,8 @@

class labelKey(PalettePlugin):


def settings( self ):
@objc.python_method
def settings(self):
self.name = 'Label Key'
self.width = 160
self.elementHeight = 16
Expand Down Expand Up @@ -51,7 +53,9 @@ def settings( self ):
color = NSUnarchiver.unarchiveObjectWithData_(colorData)
colours.append(color)
self.colours = dict(zip(colorKeys, colours))
self.order = []

@objc.python_method
def update(self, sender):
if hasattr(self.paletteView.frame, 'labels'):
delattr(self.paletteView.frame, 'labels')
Expand All @@ -62,7 +66,8 @@ def update(self, sender):
newHeight = self.elementHeight * len(self.order)
self.paletteView.frame.resize(self.width, newHeight + 10)

def draw( self, view ):
@objc.python_method
def draw(self, view):
keyDiameter = 10
height = view.bounds().size.height
for num, i in enumerate(self.order, 1):
Expand All @@ -73,7 +78,8 @@ def draw( self, view ):
self.colours[i].set()
NSBezierPath.bezierPathWithOvalInRect_(((0, height - (num * self.elementHeight)), (keyDiameter, keyDiameter))).fill()

def getKeyFile( self ):
@objc.python_method
def getKeyFile(self):
keyFile = None
try:
thisDirPath = os.path.dirname(self.windowController().document().font.filepath)
Expand All @@ -85,8 +91,8 @@ def getKeyFile( self ):
if keyFile is None:
keyFile = os.path.expanduser('~/Library/Application Support/Glyphs/Info/labelkey.txt')
return keyFile

def mapKeys( self, keyFile ):
@objc.python_method
def mapKeys(self, keyFile):
order = []
colourLabels = {}
if os.path.exists(keyFile):
Expand All @@ -107,6 +113,7 @@ def setWindowController_(self, windowController):
import traceback
self.logError(traceback.format_exc())

@objc.python_method
def __file__(self):
"""Please leave this method unchanged"""
return __file__