Vanilla object and drawing in TinyDrawbot

RoboFont Forums Help / General Vanilla object and drawing in TinyDrawbot


This topic contains 4 replies, has 2 voices, and was last updated by  Roberto Arista 2 years ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #6203

    Roberto Arista

    Hi Frederik,
    I’d like to control the TinyDrawbot Canvas through a small interface built with Vanilla.

    I am trying to achieve something similar to these example: (at the bottom of the page)

    My plugin has a draw() method where I’ve put all the drawbot drawing commands, but nothing happens in the canvas.
    Here a short example of the code structure:

    from vanilla import *
    def drawRect(side):
    class SliderDemo(object):
         def __init__(self):
             self.w = Window((200, 43))
             self.w.slider = Slider((10, 10, -10, 23),
         def sliderCallback(self, sender):

    Any suggestion about how to deal correctly with this?




    Hi Roberto

    In your example you don’t have a canvas object that is able to show drawing callbacks.

    Please see the example

    The slider just tells the canvas object to redraw itself. While getting a draw callback some drawBot methods are called to draw something into the canvas

    hope this helps

    good luck!


    Roberto Arista

    Hi Frederik,
    I’ve probably not explained correctly.
    I’d like to act on the TinyDrawbot canvas, not the mojo one (it is what I am doing now for testing).

    So, maybe I can rephrase the question in this way: is it possible to point to the TinyDrawbot/Drawbot canvas –like to the mojo one– from a vanilla object?

    I need this kind of behavior:
    but I can’t use the Variable class because I need more freedom concerning UI.

    hope this is more clear



    oh, here is an example, it is required to install the drawBot extension, get it here:

    import drawBot
    from drawBot.ui.drawView import DrawView
    from vanilla import *
    class Test(object):
        def __init__(self):
            self.w = Window((400, 400), minSize=(200, 200))
            self.w.s = Slider((10, 10, -10, 22), minValue=10, maxValue=100, value=50, callback=self.sliderCallback)
            self.w.c = DrawView((10, 40, -10, -10))
        def sliderCallback(self, sender):
            value = sender.get()
            # start a new drawing
            # add a page
            drawBot.newPage(100, 100)
            # draw something
            drawBot.rect(10, 10, value, value)
            # get the pdf data
            pdf = drawBot.pdfImage()
            # set the pdf data in the canvas

    good luck!


    Roberto Arista

    Thanks, I’ll try!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.