Dirk Meyer wrote:
> A nasty trick. You inherit from Application. When you call
> Application.stop() the menu comes back. But when you override stop()
> in your code without calling Application.stop(), you won't see the
> menu. 
>
> In fact, you can't just call Application.stop() on stop. You need to
> call it when the app behind it is gone. Looking at video.xine, you see
> it does not define stop at all. It is all in childapp.py:
>
> |  def stop(self):
> |      """
> |      Stop the Application.
> |      """
> |      if hasattr(self, 'item') and self.has_child():
> |          self.child_stop()
> |      else:
> |          base.Application.stop(self)
>
> I guess you should also inherit from application.ChildApp and not use
> the player and everything works out of the box. The functions does the
> follwing:
>
> 1. case: the plyer stops by itself. A STOP event will be send and the
>    eventhandler in xine will call self.stop(). has_child() is False
>    because the app is dead and base.Application.stop() will be called
>    to show the menu again.
>
> 2. case: The STOP event wll stop the player. The eventhandler will
>    also call that function but has_child() is true. So it will stop
>    the child. When the child is dead, we do the same as in case1.
>
> Writing this: I guess this needs some cleanup. One function doing both
> isn't easy to understand.

OK, I changed it. Call self.stop to stop the child itself. You need to
override this function. When the child is dead (== the PLAY_AND event
is there), call self.stopped().

I guess the best example for you is the video xine plugin. It has a
child and inherits from ChildApp which does all this for you. Just
remove the extra player.py in the games code and create plugins for
each game type similar to video.xine. Remeber to call all the parent
functions like xine does to make sure the stop stuff is working.



Dischi

-- 
How do UNIX gurus have sex?
Simple.

[root @ localhost] unzip; strip; touch; finger; mount; fsck; more; yes; 
umount; sleep

Attachment: pgp6Sk2XOvVVP.pgp
Description: PGP signature

Reply via email to