Exemple #1
0
 def drawRect_(self, rect):
     if self.canvas is not None:
         NSGraphicsContext.currentContext().saveGraphicsState()
         try:
             if self.zoom != 1.0:
                 t = NSAffineTransform.transform()
                 t.scaleBy_(self.zoom)
                 t.concat()
                 clip = NSBezierPath.bezierPathWithRect_(((0, 0), (self.canvas.width, self.canvas.height)))
                 clip.addClip()
             self.canvas.draw()
         except:
             # A lot of code just to display the error in the output view.
             etype, value, tb = sys.exc_info()
             if tb.tb_next is not None:
                 tb = tb.tb_next  # skip the frame doing the exec
             traceback.print_exception(etype, value, tb)
             data = "".join(traceback.format_exception(etype, value, tb))
             attrs = PyDETextView.getBasicTextAttributes()
             attrs[NSForegroundColorAttributeName] = NSColor.redColor()
             outputView = self.document.outputView
             outputView.setSelectedRange_((outputView.textStorage().length(), 0))
             outputView.setTypingAttributes_(attrs)
             outputView.insertText_(data)
         NSGraphicsContext.currentContext().restoreGraphicsState()
Exemple #2
0
 def windowControllerDidLoadNib_(self, controller):
     if self.path:
         self.readFromUTF8(self.path)
     font = PyDETextView.getBasicTextAttributes()[NSFontAttributeName]
     self.outputView.setFont_(font)
     self.textView.window().makeFirstResponder_(self.textView)
     self.windowControllers()[0].setWindowFrameAutosaveName_("NodeBoxDocumentWindow")
Exemple #3
0
 def drawRect_(self, rect):
     if self.canvas is not None:
         NSGraphicsContext.currentContext().saveGraphicsState()
         try:
             if self.zoom != 1.0:
                 t = NSAffineTransform.transform()
                 t.scaleBy_(self.zoom)
                 t.concat()
                 clip = NSBezierPath.bezierPathWithRect_(
                     ((0, 0), (self.canvas.width, self.canvas.height)))
                 clip.addClip()
             self.canvas.draw()
         except:
             # A lot of code just to display the error in the output view.
             etype, value, tb = sys.exc_info()
             if tb.tb_next is not None:
                 tb = tb.tb_next  # skip the frame doing the exec
             traceback.print_exception(etype, value, tb)
             data = "".join(traceback.format_exception(etype, value, tb))
             attrs = PyDETextView.getBasicTextAttributes()
             attrs[NSForegroundColorAttributeName] = NSColor.redColor()
             outputView = self.document.outputView
             outputView.setSelectedRange_(
                 (outputView.textStorage().length(), 0))
             outputView.setTypingAttributes_(attrs)
             outputView.insertText_(data)
         NSGraphicsContext.currentContext().restoreGraphicsState()
 def windowControllerDidLoadNib_(self, controller):
     if self.path:
         self.readFromUTF8(self.path)
     font = PyDETextView.getBasicTextAttributes()[NSFontAttributeName]
     self.outputView.setFont_(font)
     self.textView.window().makeFirstResponder_(self.textView)
     self.windowControllers()[0].setWindowFrameAutosaveName_("NodeBoxDocumentWindow")
Exemple #5
0
    def _flushOutput(self, output):
        outAttrs = PyDETextView.getBasicTextAttributes()
        errAttrs = outAttrs.copy()
        # XXX err color from user defaults...
        errAttrs[NSForegroundColorAttributeName] = NSColor.redColor()

        outputView = self.outputView
        outputView.setSelectedRange_((outputView.textStorage().length(), 0))
        lastErr = None
        for isErr, data in output:
            if isErr != lastErr:
                attrs = [outAttrs, errAttrs][isErr]
                outputView.setTypingAttributes_(attrs)
                lastErr = isErr
            outputView.insertText_(data)
Exemple #6
0
    def _flushOutput(self, output):
        outAttrs = PyDETextView.getBasicTextAttributes()
        errAttrs = outAttrs.copy()
        # XXX err color from user defaults...
        errAttrs[NSForegroundColorAttributeName] = NSColor.redColor()

        outputView = self.outputView
        outputView.setSelectedRange_((outputView.textStorage().length(), 0))
        lastErr = None
        for isErr, data in output:
            if isErr != lastErr:
                attrs = [outAttrs, errAttrs][isErr]
                outputView.setTypingAttributes_(attrs)
                lastErr = isErr
            outputView.insertText_(data)
 def drawRect_(self, rect):
     if self.canvas is not None:
         NSGraphicsContext.currentContext().saveGraphicsState()
         try:
             self.canvas.draw()
         except:
             # A lot of code just to display the error in the output view.
             etype, value, tb = sys.exc_info()
             if tb.tb_next is not None:
                 tb = tb.tb_next  # skip the frame doing the exec
             traceback.print_exception(etype, value, tb)
             data = "".join(traceback.format_exception(etype, value, tb))
             attrs = PyDETextView.getBasicTextAttributes()
             attrs[NSForegroundColorAttributeName] = NSColor.redColor()
             outputView = self.document.outputView
             outputView.setSelectedRange_((outputView.textStorage().length(), 0))
             outputView.setTypingAttributes_(attrs)
             outputView.insertText_(data)
         NSGraphicsContext.currentContext().restoreGraphicsState()
 def drawRect_(self, rect):
     if self.canvas is not None:
         NSGraphicsContext.currentContext().saveGraphicsState()
         try:
             self.canvas.draw()
         except:
             # A lot of code just to display the error in the output view.
             etype, value, tb = sys.exc_info()
             if tb.tb_next is not None:
                 tb = tb.tb_next  # skip the frame doing the exec
             traceback.print_exception(etype, value, tb)
             data = "".join(traceback.format_exception(etype, value, tb))
             attrs = PyDETextView.getBasicTextAttributes()
             attrs[NSForegroundColorAttributeName] = NSColor.redColor()
             outputView = self.document.outputView
             outputView.setSelectedRange_((outputView.textStorage().length(), 0))
             outputView.setTypingAttributes_(attrs)
             outputView.insertText_(data)
         NSGraphicsContext.currentContext().restoreGraphicsState()
Exemple #9
0
 def textFontChanged_(self, notification):
     font = PyDETextView.getBasicTextAttributes()[NSFontAttributeName]
     self.outputView.setFont_(font)
Exemple #10
0
 def textFontChanged_(self, notification):
     font = PyDETextView.getBasicTextAttributes()[NSFontAttributeName]
     self.outputView.setFont_(font)