def hitCallback(sender): script = 'fill(random(), random(), random())\nrect(10+random()*100, 10+random()*100, 200, 300)' _drawBotDrawingTool.newDrawing() namespace = DrawBotNamespace(_drawBotDrawingTool, _drawBotDrawingTool._magicVariables) _drawBotDrawingTool._addToNamespace(namespace) # Creates a new standard output, catching all print statements and tracebacks. output = [] stdout = StdOutput(output, outputView=outputWindow.outputView) stderr = StdOutput(output, isError=True, outputView=outputWindow.outputView) # Calls DrawBot's ScriptRunner with above parameters. ScriptRunner(script, None, namespace=namespace, stdout=stdout, stderr=stderr) context = getContextForFileExt('pdf') _drawBotDrawingTool._drawInContext(context) pdfDocument = _drawBotDrawingTool.pdfImage() w.drawView.setPDFDocument(pdfDocument)
def createContext(context): # draw the tool in to the context _drawBotDrawingTool._drawInContext(context)
def displayDrawing(self): context = DrawBotContext() _drawBotDrawingTool._drawInContext(context) self.w.dbView.setPDFDocument(context.getNSPDFDocument())
def createContext(context): # draw the tool in to the context _drawBotDrawingTool._drawInContext(context)
def getPageBotDocument(self): """Converts template drawn in memory to a PDF document.""" context = getContextForFileExt('pdf') _drawBotDrawingTool._drawInContext(context) pdfDocument = _drawBotDrawingTool.pdfImage() return pdfDocument