Having a go at assembling a script with a Vanilla UI. Essentially it will provide a list to make a selection (fonts in a folder), and then a button to go on to perform actions on that selection (generate specimen images with Drawbot).
I can make the list and create the button, but I can’t figure out how to make the selection get passed on. In fact my script seems never to get to the button’s callback.
In looking at the Vanilla documentation, I found that even their simple sample scripts weren’t working on my system. This for example never reports “button hit!”:
from vanilla import *
class ButtonDemo(object):
def __init__(self):
self.w = Window((100, 40))
self.w.button = Button((10, 10, -10, 20), "A Button",
callback=self.buttonCallback)
self.w.open()
def buttonCallback(self, sender):
print ("button hit!")
ButtonDemo()
(Taken straight from the Vanilla doc (with parentheses added to print line.)) And likewise, this makes the list but doesn’t report what was selected (nothing appears in console):
The selectionCallback is probably only called when you click a row in the table.
Try to put the print statement into the button callback.
But you might consider a different UI. Why build something that looks a bit like the Finder when you can use a Finder window and 1) drag the fonts into your window or 2) use apple Script to get the selected files from the Fonder?
in the Glyphs macro window, all works fine. If I run it in the Drawbot plugin window, The “Print statement” appears in the Drawbot console but the “Button callback” appears in the Glyphs console! If I run it in the standalone Drawbot app (which is where I was trying to develop my script) I see “Print statement” in its console, and “Button callback” is nowhere I can see.