def with_canvas(self, proc): NSGraphicsContext.__class__.saveGraphicsState() NSGraphicsContext.setCurrentContext_(self._ns_graphics_context) try: canvas = Canvas() proc(canvas) finally: NSGraphicsContext.__class__.restoreGraphicsState()
def drawRect_(self, ns_rect): (l, t), (w, h) = ns_rect rect = (l, t, l + w, t + h) self.pygui_component.draw(Canvas(), rect)
def with_canvas(self, proc): ns_view = self._ns_view ns_view.lockFocus() proc(Canvas()) ns_view.unlockFocus()