Ejemplo n.º 1
0
 def set_mode(self, size, buffered=True, *args, **kwargs):
     """
     Setup the display Surface.
     Argument include size (x,y) of surface and optional buffered surface.
     Return a reference to the display Surface.
     """
     self.canvas = Canvas(size, buffered)
     env.set_env('canvas', self.canvas)
     self.frame = Window.getDocumentRoot()
     env.set_env('frame', self.frame)
     panel = SimplePanel(Widget=self.canvas)
     RootPanel().add(panel)
     self.panel = panel
     self.vpanel = None
     self.textbox = None
     self.textarea = None
     self.Textbox = Textbox
     self.Textarea = Textarea
     self.surface = self.canvas.surface
     self.surface._display = self
     self._surface_rect = self.surface.get_rect()
     if not self.canvas._bufferedimage:
         self.flip = lambda: None
         self.update = lambda *arg: None
     return self.surface
Ejemplo n.º 2
0
def init():
    """
    Initialize module.
    """
    global time, display, image, event, key, mouse, mixer, _initialized
    if _initialized:
        return
    else:
        _initialized = True
    event = Event()
    env.set_env('event', event)
    time = Time()
    display = Display()
    image = Image()
    mixer = Mixer()
    mouse = Mouse()
    key = Key()
Ejemplo n.º 3
0
        else:
            return False, True

    def test_getattr(self):
        """
        Test if object __getattr__ method is called.
        """
        return (Rect(0,0,20,20).center == (10,10))

    def test_eq(self):
        """
        Test if object __eq__ method is called.
        """
        return (Rect(0,0,20,20) == Rect(0,0,20,20))

env.set_env('pyjs_mode', PyjsMode())


def call(obj, func, args=()):
    """
    Call unbound method.
    Argument obj is the object, func is the unbound method, and optional args is a tuple of arguments for the method.
    Returns the method's return value.
    """
    return JS("@{{func}}.apply(@{{obj}}, @{{args}}['getArray']());")


#code modified from pyjs
class _dict(dict):

    def values(self):