-
Notifications
You must be signed in to change notification settings - Fork 4
/
newTabModifiedGlyphs.py
58 lines (46 loc) · 1.58 KB
/
newTabModifiedGlyphs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#MenuTitle: New tab with modified glyphs
# -*- coding: utf-8 -*-
__doc__="""
(UI) Opens in a new tab modified glyphs after or before certain date.
"""
from GlyphsApp import *
from vanilla import *
import time
import datetime
glyphList = []
thisFont = Glyphs.font
class openGlyphs(object):
def __init__(self):
self.w = Window((240, 115), "New tab with modified glyphs")
self.w.radioGroup = RadioGroup((10, 10, 140, 40), ["After", "Before"], isVertical=False)
self.w.fechaPick = DatePicker((10, 50, -10, 22), timeDisplay=None)
self.w.goButton = Button((10, -30, -10, 20), "Open in a new tab", callback=self.buttonCallback)
self.w.radioGroup.set(0)
self.w.open()
def buttonCallback(self, sender):
Glyphs.showMacroWindow()
Glyphs.clearLog()
pickedDate = self.w.fechaPick.get()
split1 = str(pickedDate).split(' ')[0]
split2 = split1.split('-')
year = int(split2[0])
month = int(split2[1])
day = int(split2[2])
date = datetime.date(year,month,day)
unixtime = time.mktime(date.timetuple())
optionChoice = self.w.radioGroup.get()
## #sortedglyphList = sorted(glyphList, key=lambda x: x[1])
for glyph in Font.glyphs:
if optionChoice == 0:
if glyph.lastChange > unixtime:
glyphList.append(glyph.name)
else:
if glyph.lastChange < unixtime:
glyphList.append(glyph.name)
tabString = "/%s" % "/".join(glyphList)
thisFont.newTab( tabString )
for glyph in glyphList:
thisGlyph = thisFont.glyphs[glyph]
lastChange = time.strftime("%d/%m/%y", time.localtime(thisGlyph.lastChange))
print (thisGlyph.name+": "+lastChange)
openGlyphs()