Web · Wiki · Activities · Blog · Lists · Chat · Meeting · Bugs · Git · Translate · Archive · People · Donate

Commit 7f8f78bfbce3406981c203c878a892e1065e4e4d

Make Pygame display size match the widget size.
Also rename _canvas member to _pygamecanvas to avoid conflict with Sugar.
  
7070 self._inner_evb.connect('expose-event', self._expose_cb)
7171 self._inner_evb.connect('configure-event', self._resize_cb)
7272
73 # Fake the first VIDEORESIZE event to set the initial screen dimensions.
74 r = self._inner_evb.get_allocation()
75 evt = pygame.event.Event(pygame.VIDEORESIZE,
76 size=(r.width,r.height), width=r.width, height=r.height)
77 pygame.event.post(evt)
78
7379 # Internal data
7480 self.__stopped = False
7581 self.__keystate = [0] * 323
9898 return True
9999
100100 def _resize_cb(self, widget, event):
101 evt = pygame.event.Event(pygame.event.VIDEORESIZE,
101 evt = pygame.event.Event(pygame.VIDEORESIZE,
102102 size=(event.width,event.height), width=event.width, height=event.height)
103103 pygame.event.post(evt)
104104 return False # continue processing
  
2525 self.build_toolbar()
2626
2727 # Build the Pygame canvas.
28 self._canvas = sugargame.canvas.PygameCanvas(self)
28 self._pygamecanvas = sugargame.canvas.PygameCanvas(self)
2929 # Note that set_canvas implicitly calls read_file when resuming from the Journal.
30 self.set_canvas(self._canvas)
30 self.set_canvas(self._pygamecanvas)
3131
3232 # Start the game running.
33 self._canvas.run_pygame(self.game.run)
33 self._pygamecanvas.run_pygame(self.game.run)
3434
3535 def build_toolbar(self):
3636 stop_play = sugar.graphics.toolbutton.ToolButton('media-playback-stop')
  
4141 for event in pygame.event.get():
4242 if event.type == pygame.QUIT:
4343 return
44
44 elif event.type == pygame.VIDEORESIZE:
45 pygame.display.set_mode(event.size, pygame.RESIZABLE)
46
4547 # Move the ball
4648 if not self.paused:
4749 self.x += self.vx