[Tutor] gui further explained

Wayne srilyk at gmail.com
Wed Jun 10 12:20:28 CEST 2009

On Tue, Jun 9, 2009 at 10:31 PM, Essah Mitges <e_mitges at hotmail.com> wrote:

> i don't know if its what i am searching that is wrong but what i am trying
> to do is
> link my game i made in pygame to my pygame menu the menu has 4 button
> classes on it one foe instruction one to quit one for high scores and one to
> start the game
> the 3 other buttons work all but the one to start the game this is basicly
> the menu i want people to see first the main menu

So why don't you put your menu in your game?

Consider the following:

# Lamegame.py - probably the lamest game ever!

print "Welcome to Lame Game!"
raw_input("Please type something and press enter: ")
print "You win!"

So there's a game. Now let's add a menu:

# lamegameimproved.py - the lamest game, now with a menu!

import sys

print "Welcome to Lame Game!"
print "\nMenu:\n"
print "(Q)uit"
print "(P)lay"
choice = raw_input("Your Choice? (P or Q): ")

if choice.lower() == 'q':
elif choice.lower() == 'p':
    # add original code here

See? Quite simple. Even with pygame it shouldn't be a whole lot more complex
than that. And that's really the most simple example I could think of and
it's really not very good. For instance you could put the original code into
a "game" function and then call it if the choice was P.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090610/db915ec2/attachment.htm>

More information about the Tutor mailing list