-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnewTabMoreThanXComponents.py
executable file
·52 lines (35 loc) · 1.26 KB
/
newTabMoreThanXComponents.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
#MenuTitle: New tab with more than x components
# -*- coding: utf-8 -*-
__doc__="""
(UI) Opens in a new tab the glyphs with more than the indicated ammout of components
"""
import GlyphsApp
from vanilla import *
thisFont = Glyphs.font
selectedLayers = thisFont.selectedLayers
class newTabXComponents(object):
def __init__(self):
compAmount = 1
self.w = FloatingWindow((250, 90), "Amount of components")
self.w.EditText = TextBox((10, 10, 250, 20), "New tab with glyphs with")
self.w.EditText2 = TextBox((10, 35, 90, 20), "more than")
self.w.textBox = EditText((78, 35, 30, 20), compAmount)
self.w.EditText3 = TextBox((110, 35, 90, 20), "components")
self.w.button = Button((10, 60, -10, 20), "Check & Open",
callback=self.buttonCallback)
self.w.open()
def buttonCallback(self, sender):
lista = []
amoutOfComponents = self.w.textBox.get()
for thisLayer in selectedLayers:
if len( thisLayer.components ) > int(amoutOfComponents):
thisGlyph = thisLayer.parent
lista.append(thisGlyph.name)
if len(lista) > 0:
tabString = "/%s" % "/".join(lista)
thisFont.newTab( tabString )
else:
Glyphs.clearLog()
Glyphs.showMacroWindow()
print ("No glyphs with more than", amoutOfComponents, "components")
newTabXComponents()