vanilla is Python wrapper around Apple’s native Cocoa UI layer. It offers a pythonic API for creating interfaces with code, rather than using visual tools like Apple’s Interface Builder.

Using vanilla

vanilla is embedded in RoboFont, so you can start using it right away:

from vanilla import *

vanilla includes very complete documentation for all its objects, available directly from your scripting environment:

from vanilla import *

help(Window)

The above line will return the full inline documentation for the Window object, including some sample code:

from vanilla import *

class WindowDemo(object):

    def __init__(self):
        self.w = Window((200, 70), "Window Demo")
        self.w.myButton = Button((10, 10, -10, 20), "My Button")
        self.w.myTextBox = TextBox((10, 40, -10, 17), "My Text Box")
        self.w.open()

WindowDemo()

If you run the above code, you will get this simple demo window:

vanilla overview

Below is an overview of all UI elements included in vanilla. These images are simple screenshots from vanilla’s own test files, which are included in the library.

from vanilla.test.testAll import Test
Test()
windows
text objects
buttons, sliders, etc.
views
toolbar

The List test crashes RoboFont.

Last edited on 27/03/2018