mojo.canvas

class CanvasGroup()

Deprecated. Use Merz to draw on screen.

A vanilla object that sends all events to a given delegate.

All events that a delegate could have can be used:

  • draw()
  • becomeFirstResponder(event)
  • resignFirstResponder(event)
  • mouseDown(event)
  • mouseDragged(event)
  • mouseUp(event)
  • mouseMoved(event) (only when acceptsMouseMoved is set to True)
  • rightMouseDown(event)
  • rightMouseDragged(event)
  • rightMouseUp(event)
  • mouseEntered(event)
  • mouseExited(event)
  • scrollWheel(event)
  • magnifyWithEvent(event)
  • rotateWithEvent(event)
  • swipeWithEvent(event)
  • keyDown(event)
  • keyUp(event)
  • flagChanged(event)
  • menu(event)
  • shouldDrawBackground() (return False for no background color)
  • updateTrackingAreas() (return a list of bounds rectangles [(x, y, w, h)), (x, y, w, h)])
from mojo.canvas import CanvasGroup
from mojo.drawingTools import *
from vanilla import Window

class ExampleWindow:

    def __init__(self):
        self.w = Window((400, 400), minSize=(200, 200))
        self.w.canvas = CanvasGroup((0, 0, -0, -0), delegate=self)
        self.w.open()

    def draw(self):
        rect(10, 10, 100, 100)

ExampleWindow()
Inherits from subclass: mojo.canvas.CanvasGroup

height()

Return the height of the canvas.

width()

Return the width of the canvas.

class Canvas()

Deprecated. Use Merz to draw on screen.

A vanilla scroll view that sends all events to a given delegate

All events that a delegate could have can be used:

  • draw()
  • becomeFirstResponder(event)
  • resignFirstResponder(event)
  • mouseDown(event)
  • mouseDragged(event)
  • mouseUp(event)
  • mouseMoved(event) (only when acceptsMouseMoved is set True)
  • rightMouseDown(event)
  • rightMouseDragged(event)
  • rightMouseUp(event)
  • mouseEntered(event)
  • mouseExited(event)
  • scrollWheel(event)
  • magnifyWithEvent(event)
  • rotateWithEvent(event)
  • swipeWithEvent(event)
  • keyDown(event)
  • keyUp(event)
  • flagChanged(event)
  • menu(event)
  • shouldDrawBackground() (return False for no background color)
  • updateTrackingAreas() (return a list of bounds rectangles [(x, y, w, h)), (x, y, w, h)])
from mojo.canvas import Canvas
from mojo.drawingTools import *
from vanilla import Window

class ExampleWindow:

    def __init__(self):
        self.w = Window((400, 400), minSize=(200, 200))
        self.w.canvas = Canvas((0, 0, -0, -0), delegate=self)
        self.w.open()

    def draw(self):
        rect(10, 10, 100, 100)

ExampleWindow()
Inherits from subclass: mojo.canvas.Canvas
Last edited on 08/12/2024