Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
    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()
Ejemplo n.º 3
0
    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()