def transformedValue_(self, priority):
     if priority is None:
         return NSColor.blackColor()
     elif priority > 4:
         return NSColor.redColor()
     elif priority > 3:
         return NSColor.orangeColor()
     elif priority > 2:
         return NSColor.blueColor()
     elif priority > 1:
         return NSColor.greenColor()
     elif priority > 0:
         return NSColor.brownColor()
     else:
         return NSColor.blackColor()
    def arrangeObjects_(self, objects):
        "Filtering is not yet connected in IB!"
        # XXX: This doesn't work yet, so disable
        if self.shouldFilter:
            self.shouldFilter = False

        if not self.shouldFilter:
            return super(GraphicsArrayController,
                         self).arrangeObjects_(objects)

        if self.filterColor is None:
            self.filterColor = NSColor.blackColor().colorUsingColorSpaceName_(
                NSCalibratedRGBColorSpace)

        filterHue = self.filterColor.hueComponent()
        filteredObjects = []
        for item in objects:
            hue = item.color.hueComponent()
            if ((fabs(hue - filterHue) < 0.05)
                    or (fabs(hue - filterHue) > 0.95)
                    or (item is self.newCircle)):
                filteredObjects.append(item)
                self.newCircle = None
        return super(GraphicsArrayController,
                     self).arrangeObjects_(filteredObjects)
 def initWithFrame_(self, frame):
     self.color = NSColor.blackColor()
     self.pixel_buffer = numpy.zeros((256, 256), numpy.uint8)
     self.blob = numpy.zeros((16, 16), numpy.uint8)
     self.blob += 16
     self.t = .0
     self.now = time.time()
     self.xfac = 3.5
     self.yfac = 2.5
     return super(ApplicationView, self).initWithFrame_(frame)
Example #4
0
 def initWithFrame_(self, frame):
     self.backgroundColor = NSColor.blackColor()
     self.graphColor = NSColor.whiteColor()
     self.maxRssiColor = self.graphColor.colorWithAlphaComponent_(0.8)
     self._last_ts = None
     self._last_display = None
     self._rssi_values = []
     self._max_rssi = 0
     self._capture = None
     self._retained_samples = self.RETAINED_SAMPLES_START
     self._filtered_value_per_second = self.SAMPLEERATE
     return super(LaptimerView, self).initWithFrame_(frame)
Example #5
0
 def awakeFromNib(self):
     self.setFont_(NSFont.userFixedPitchFontOfSize_(10))
     self.p_colors = {
         "stderr": NSColor.redColor(),
         "stdout": NSColor.blueColor(),
         "code": NSColor.blackColor(),
     }
     self.setHistoryLength_(50)
     self.setHistoryView_(0)
     self.setInteracting_(False)
     self.setAutoScroll_(True)
     self.setSingleLineInteraction_(False)
     self.p_history = [""]
     self.p_input_callbacks = []
     self.p_input_lines = []
     self.setupTextView()
     self.interpreter.connect()
Example #6
0
 def awakeFromNib(self):
     self = super(PyInterpreter, self).init()
     self._font = NSFont.userFixedPitchFontOfSize_(10)
     self._stderrColor = NSColor.redColor()
     self._stdoutColor = NSColor.blueColor()
     self._codeColor = NSColor.blackColor()
     self._historyLength = 50
     self._history = [""]
     self._historyView = 0
     self._characterIndexForInput = 0
     self._stdin = PseudoUTF8Input(self._nestedRunLoopReaderUntilEOLchars_)
     # self._stdin = PseudoUTF8Input(self.readStdin)
     self._stderr = PseudoUTF8Output(self.writeStderr_)
     self._stdout = PseudoUTF8Output(self.writeStdout_)
     self._isInteracting = False
     self._console = AsyncInteractiveConsole()
     self._interp = self._console.asyncinteract(write=self.writeCode_).next
     self._autoscroll = True
     self.applicationDidFinishLaunching_(None)
Example #7
0
 def awakeFromNib(self):
     self = super(PyInterpreter, self).init()
     self._font = NSFont.userFixedPitchFontOfSize_(10)
     self._stderrColor = NSColor.redColor()
     self._stdoutColor = NSColor.blueColor()
     self._codeColor = NSColor.blackColor()
     self._historyLength = 50
     self._history = ['']
     self._historyView = 0
     self._characterIndexForInput = 0
     self._stdin = PseudoUTF8Input(self._nestedRunLoopReaderUntilEOLchars_)
     #self._stdin = PseudoUTF8Input(self.readStdin)
     self._stderr = PseudoUTF8Output(self.writeStderr_)
     self._stdout = PseudoUTF8Output(self.writeStdout_)
     self._isInteracting = False
     self._console = AsyncInteractiveConsole()
     self._interp = partial(next, self._console.asyncinteract(
         write=self.writeCode_,
     ))
     self._autoscroll = True
    def arrangeObjects_(self, objects):
        "Filtering is not yet connected in IB!"
        # XXX: This doesn't work yet, so disable
        if self.shouldFilter:
            self.shouldFilter = False

        if not self.shouldFilter:
            return super(GraphicsArrayController, self).arrangeObjects_(objects)

        if self.filterColor is None:
            self.filterColor = NSColor.blackColor().colorUsingColorSpaceName_(NSCalibratedRGBColorSpace)

        filterHue = self.filterColor.hueComponent()
        filteredObjects = []
        for item in objects:
            hue = item.color.hueComponent()
            if ((fabs(hue - filterHue) < 0.05) or
                (fabs(hue - filterHue) > 0.95) or
                (item is self.newCircle)):
                filteredObjects.append(item)
                self.newCircle = None
        return super(GraphicsArrayController, self).arrangeObjects_(filteredObjects)
Example #9
0
 def drawRect_(self, rect):
     f = self.frame()
     f.origin.x = f.origin.y = 0.0
     color = NSColor.blackColor()
     color.set()
     NSBezierPath.fillRect_(f)
 def init(self):
     self = super(ApplicationDelegate, self).init()
     self.colors = [NSColor.blackColor(), NSColor.redColor(), NSColor.greenColor()]
     return self
Example #11
0
    def drawRect_(self, rect):
        """
        Basic goals here:
        If either the angle or the offset has a "bad selection":
        then draw a gray rectangle, and that's it.
        Note: bad selection is set if there's a multiple selection
        but the "allows multiple selection" binding is NO.

        If there's a multiple selection for either angle or offset:
        then what you draw depends on what's multiple.

        - First, draw a white background to show all's OK.

        - If both are multiple, then draw a special symbol.

        - If offset is multiple, draw a line from the center of the view
        - to the edge at the shared angle.

        - If angle is multiple, draw a circle of radius the shared offset
        - centered in the view.

        If neither is multiple, draw a cross at the center of the view
        and a cross at distance 'offset' from the center at angle 'angle'
        """
        myBounds = self.bounds()
        if self.badSelectionForAngle or self.badSelectionForOffset:
            # "disable" and exit
            NSDrawDarkBezel(myBounds, myBounds)
            return
        # user can do something, so draw white background and
        # clip in anticipation of future drawing
        NSDrawLightBezel(myBounds, myBounds)
        clipRect = NSBezierPath.bezierPathWithRect_(
            NSInsetRect(myBounds, 2.0, 2.0))
        clipRect.addClip()

        if self.multipleSelectionForAngle or self.multipleSelectionForOffset:
            originOffsetX = myBounds.size.width / 2 + 0.5
            originOffsetY = myBounds.size.height / 2 + 0.5
            if self.multipleSelectionForAngle and self.multipleSelectionForOffset:
                # draw a diagonal line and circle to denote
                # multiple selections for angle and offset
                NSBezierPath.strokeLineFromPoint_toPoint_(
                    NSMakePoint(0, 0),
                    NSMakePoint(myBounds.size.width, myBounds.size.height),
                )
                circleBounds = NSMakeRect(originOffsetX - 5, originOffsetY - 5,
                                          10, 10)
                path = NSBezierPath.bezierPathWithOvalInRect_(circleBounds)
                path.stroke()
                return
            if self.multipleSelectionForOffset:
                # draw a line from center to a point outside
                # bounds in the direction specified by angle
                angleRadians = self.angle * (pi / 180.0)
                x = sin(angleRadians) * myBounds.size.width + originOffsetX
                y = cos(angleRadians) * myBounds.size.height + originOffsetX
                NSBezierPath.strokeLineFromPoint_toPoint_(
                    NSMakePoint(originOffsetX, originOffsetY),
                    NSMakePoint(x, y))
                return
            if self.multipleSelectionForAngle:
                # draw a circle with radius the shared offset
                # dont' draw radius < 1.0, else invisible
                drawRadius = self.offset
                if drawRadius < 1.0:
                    drawRadius = 1.0
                offsetBounds = NSMakeRect(
                    originOffsetX - drawRadius,
                    originOffsetY - drawRadius,
                    drawRadius * 2,
                    drawRadius * 2,
                )
                path = NSBezierPath.bezierPathWithOvalInRect_(offsetBounds)
                path.stroke()
                return
            # shouldn't get here
            return
        trans = NSAffineTransform.transform()
        trans.translateXBy_yBy_(myBounds.size.width / 2 + 0.5,
                                myBounds.size.height / 2 + 0.5)
        trans.concat()
        path = NSBezierPath.bezierPath()

        # draw + where shadow extends
        angleRadians = self.angle * (pi / 180.0)
        xOffset = sin(angleRadians) * self.offset
        yOffset = cos(angleRadians) * self.offset

        path.moveToPoint_(NSMakePoint(xOffset, yOffset - 5))
        path.lineToPoint_(NSMakePoint(xOffset, yOffset + 5))
        path.moveToPoint_(NSMakePoint(xOffset - 5, yOffset))
        path.lineToPoint_(NSMakePoint(xOffset + 5, yOffset))

        NSColor.lightGrayColor().set()
        path.setLineWidth_(1.5)
        path.stroke()

        # draw + in center of view
        path = NSBezierPath.bezierPath()

        path.moveToPoint_(NSMakePoint(0, -5))
        path.lineToPoint_(NSMakePoint(0, +5))
        path.moveToPoint_(NSMakePoint(-5, 0))
        path.lineToPoint_(NSMakePoint(+5, 0))

        NSColor.blackColor().set()
        path.setLineWidth_(1.0)
        path.stroke()
 def transformedValue_(self, aDate):
     if aDate is None:
         return None
     if aDate.timeIntervalSinceNow() < 0:
         return NSColor.redColor()
     return NSColor.blackColor()
Example #13
0
 def initWithFrame_(self, frame):
     self.backgroundColor = NSColor.blackColor()
     self.barColor = NSColor.whiteColor()
     self.channelValues = [0] * self.CHANNELS
     return super(ScanView, self).initWithFrame_(frame)
Example #14
0
    def drawRect_(self, rect):
        """
        Basic goals here:
        If either the angle or the offset has a "bad selection":
        then draw a gray rectangle, and that's it.
        Note: bad selection is set if there's a multiple selection
        but the "allows multiple selection" binding is NO.

        If there's a multiple selection for either angle or offset:
        then what you draw depends on what's multiple.

        - First, draw a white background to show all's OK.

        - If both are multiple, then draw a special symbol.

        - If offset is multiple, draw a line from the center of the view
        - to the edge at the shared angle.

        - If angle is multiple, draw a circle of radius the shared offset
        - centered in the view.

        If neither is multiple, draw a cross at the center of the view
        and a cross at distance 'offset' from the center at angle 'angle'
        """
        myBounds = self.bounds()
        if self.badSelectionForAngle or self.badSelectionForOffset:
            # "disable" and exit
            NSDrawDarkBezel(myBounds,myBounds);
            return;
        # user can do something, so draw white background and
        # clip in anticipation of future drawing
        NSDrawLightBezel(myBounds,myBounds)
        clipRect = NSBezierPath.bezierPathWithRect_(NSInsetRect(myBounds,2.0,2.0))
        clipRect.addClip()

        if self.multipleSelectionForAngle or self.multipleSelectionForOffset:
            originOffsetX = myBounds.size.width/2 + 0.5
            originOffsetY = myBounds.size.height/2 + 0.5
            if self.multipleSelectionForAngle and self.multipleSelectionForOffset:
                # draw a diagonal line and circle to denote
                # multiple selections for angle and offset
                NSBezierPath.strokeLineFromPoint_toPoint_(NSMakePoint(0,0), NSMakePoint(myBounds.size.width,myBounds.size.height))
                circleBounds = NSMakeRect(originOffsetX-5, originOffsetY-5, 10, 10)
                path = NSBezierPath.bezierPathWithOvalInRect_(circleBounds)
                path.stroke()
                return
            if self.multipleSelectionForOffset:
                # draw a line from center to a point outside
                # bounds in the direction specified by angle
                angleRadians = self.angle * (pi/180.0)
                x = sin(angleRadians) * myBounds.size.width + originOffsetX
                y = cos(angleRadians) * myBounds.size.height + originOffsetX
                NSBezierPath.strokeLineFromPoint_toPoint_(NSMakePoint(originOffsetX, originOffsetY),
                    NSMakePoint(x, y))
                return
            if self.multipleSelectionForAngle:
                # draw a circle with radius the shared offset
                # dont' draw radius < 1.0, else invisible
                drawRadius = self.offset
                if drawRadius < 1.0: drawRadius = 1.0
                offsetBounds = NSMakeRect(originOffsetX-drawRadius,
                         originOffsetY-drawRadius,
                         drawRadius*2, drawRadius*2)
                path = NSBezierPath.bezierPathWithOvalInRect_(offsetBounds)
                path.stroke()
                return
            # shouldn't get here
            return
        trans = NSAffineTransform.transform()
        trans.translateXBy_yBy_( myBounds.size.width/2 + 0.5, myBounds.size.height/2 + 0.5)
        trans.concat()
        path = NSBezierPath.bezierPath()

        # draw + where shadow extends
        angleRadians = self.angle * (pi/180.0)
        xOffset = sin(angleRadians) * self.offset
        yOffset = cos(angleRadians) * self.offset

        path.moveToPoint_(NSMakePoint(xOffset,yOffset-5))
        path.lineToPoint_(NSMakePoint(xOffset,yOffset+5))
        path.moveToPoint_(NSMakePoint(xOffset-5,yOffset))
        path.lineToPoint_(NSMakePoint(xOffset+5,yOffset))

        NSColor.lightGrayColor().set()
        path.setLineWidth_(1.5)
        path.stroke()

        # draw + in center of view
        path = NSBezierPath.bezierPath()

        path.moveToPoint_(NSMakePoint(0,-5))
        path.lineToPoint_(NSMakePoint(0,+5))
        path.moveToPoint_(NSMakePoint(-5,0))
        path.lineToPoint_(NSMakePoint(+5,0))

        NSColor.blackColor().set()
        path.setLineWidth_(1.0)
        path.stroke()
Example #15
0
 def transformedValue_(self, aDate):
     if aDate is None:
         return None
     if aDate.timeIntervalSinceNow() < 0:
         return NSColor.redColor()
     return NSColor.blackColor()
Example #16
0
 def drawRect_(self, rect):
     f = self.frame()
     f.origin.x = f.origin.y = 0.0
     color = NSColor.blackColor()
     color.set()
     NSBezierPath.fillRect_(f)