[Sugar-devel] KukuAnakula: handle quit event

Alan Jhonn Aguiar Schwyn alanjas at hotmail.com
Tue Oct 15 21:29:38 EDT 2013


Hi,
This activity was written by Julius B. Lucks, Adrian DelMaestro, Sera L. Youngin early 2007.Some time ago I found it and check if it was on ASLO. I'm not found anddecide create a GIT repo [1] and make the changes for new sugar versions.I only change the basic things such as olpcgames -> sugargames library.Your patch was pushed.
> Here's a hack patch to make this work. I think the more normal approach> is to write the app more like a state machine, with only one place that> handles and swallows pygame events, leading to just one place where this> event could be neatly handled.
Patchs are welcome :-)
Regards!
Alan
[1] http://git.sugarlabs.org/kukuanakula
> From: dsd at laptop.org
> To: alanjas at hotmail.com
> Date: Tue, 15 Oct 2013 14:43:30 -0400
> CC: sugar-devel at lists.sugarlabs.org; gruiz at fundacionzt.org
> Subject: [Sugar-devel] KukuAnakula: handle quit event
> 
> Hi,
> 
> We are looking at deploying Kuku Anakula in Nicaragua, thanks for writing
> this activity.
> 
> One problem is that the stop button doesn't actually cause the process
> to terminate. Notably, the music keeps playing and never stops, even though
> the activity has disappeared.
> 
> Here's a hack patch to make this work. I think the more normal approach
> is to write the app more like a state machine, with only one place that
> handles and swallows pygame events, leading to just one place where this
> event could be neatly handled.
> 
> --- kuku.py	2012-05-27 06:21:36.000000000 +0000
> +++ /home/olpc/kuku.py	2013-10-15 18:34:17.174872806 +0000
> @@ -595,7 +595,9 @@
>                  gtk.main_iteration()
>              events = pygame.event.get()
>              for evt in events:
> -                if evt.type == pygame.KEYDOWN:
> +                if evt.type == pygame.QUIT:
> +                    sys.exit(0)
> +                elif evt.type == pygame.KEYDOWN:
>                      qa,num_players,score,time_clock = self.game_start(screen,gridsize,font)
>                      return (qa,num_players,score,time_clock)
>  
> @@ -616,7 +618,9 @@
>                  gtk.main_iteration()
>              events = pygame.event.get()
>              for evt in events:
> -                if evt.type == pygame.KEYDOWN:
> +                if evt.type == pygame.QUIT:
> +                    sys.exit(0)
> +                elif evt.type == pygame.KEYDOWN:
>                      qa,num_players,score,time_clock = self.game_start(screen,gridsize,font,started=1)
>                      score.set(state.score)
>                      return (qa,num_players,score,time_clock)
> @@ -653,7 +657,9 @@
>                      gtk.main_iteration()
>                  events = pygame.event.get()
>                  for evt in events:
> -                    if evt.type == pygame.KEYDOWN:
> +                    if evt.type == pygame.QUIT:
> +                        sys.exit(0)
> +                    elif evt.type == pygame.KEYDOWN:
>                          qa,num_players,score,time_clock = self.reset_board(screen,gridsize,font)
>                          return (qa,num_players,score,time_clock)
>          else:
> @@ -824,8 +830,9 @@
>  
>              events = pygame.event.get()
>              for evt in events:
> -
> -                if evt.type == pygame.KEYDOWN:
> +                if evt.type == pygame.QUIT:
> +                    sys.exit(0)
> +                elif evt.type == pygame.KEYDOWN:
>                      # elif evt.key == pygame.K_SPACE:
>                      if not evt.key in move_keys:
>                          x = player.grid_position[0]
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20131015/583e35d5/attachment-0001.html>


More information about the Sugar-devel mailing list