def draw(self, canvas, x, y): #specifies top left corner canvas.saveState() height = self._getHeight() canvas.rect(x, y - height, 6 * inch, height) #first draw the text canvas.setTextOrigin(x + 3 * inch, y - 12) canvas.setFont('Times-Roman', 10) canvas.textLines(self.comment1) drawCode(canvas, self.code) canvas.textLines(self.comment2) #now a box for the drawing, slightly within rect canvas.rect(x + 9, y - height + 9, 198, height - 18) #boundary: self.namespace = {'canvas': canvas, 'cm': cm, 'inch': inch} canvas.translate(x + 9, y - height + 9) codeObj = compile(self.code, '<sample>', 'exec') exec(codeObj, self.namespace) canvas.restoreState()
def draw(self, canvas, x, y): # specifies top left corner canvas.saveState() height = self._getHeight() canvas.rect(x, y - height, 6 * inch, height) # first draw the text canvas.setTextOrigin(x + 3 * inch, y - 12) canvas.setFont("Times-Roman", 10) canvas.textLines(self.comment1) drawCode(canvas, self.code) canvas.textLines(self.comment2) # now a box for the drawing, slightly within rect canvas.rect(x + 9, y - height + 9, 198, height - 18) # boundary: self.namespace = {"canvas": canvas, "cm": cm, "inch": inch} canvas.translate(x + 9, y - height + 9) codeObj = compile(self.code, "<sample>", "exec") exec codeObj in self.namespace canvas.restoreState()
def draw(self, canvas, x, y): #specifies top left corner canvas.saveState() height = self._getHeight() canvas.rect(x, y-height, 6*inch, height) #first draw the text canvas.setTextOrigin(x + 3 * inch, y - 12) canvas.setFont('Times-Roman',10) canvas.textLines(self.comment1) drawCode(canvas, self.code) canvas.textLines(self.comment2) #now a box for the drawing, slightly within rect canvas.rect(x + 9, y - height + 9, 198, height - 18) #boundary: self.namespace = {'canvas':canvas,'cm': cm,'inch':inch} canvas.translate(x+9, y - height + 9) codeObj = compile(self.code, '<sample>','exec') exec(codeObj, self.namespace) canvas.restoreState()