[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Menu Selection



I hope you don't mind, but I snagged it for a look as well. I am not exactly making menus, but I am trying to get a better understanding on making "buttons" (I only have to make 108 of em for my 20 card keno) I have been collecting bits of code and experimenting to learn.




 --- On Wed 04/25, Dave LeCompte (really) < dave@xxxxxxxxxxxx > wrote:
From: Dave LeCompte (really) [mailto: dave@xxxxxxxxxxxx]
To: pygame-users@xxxxxxxx
Date: Wed, 25 Apr 2007 15:25:14 -0700 (PDT)
Subject: Re: [pygame] Menu Selection

"Luke Paireepinart" <rabidpoobear@xxxxxxxxx>> Simon Jackson wrote:>> Hello, I want to make a program that lets you select an item from a>> list. Check out the screenshot below for an example:>>>> http://lemonlauncher.sourceforge.net/snap/snap3.png>>>> Can anyone point me to a tutorial or something similar that will show>> me how to do this?> If you have a series of rects that describe the menu boxes, it's trivial> to do a point-rect collision with your> list of menu items and the coordinates of the mouse.> Hints: pygame.mouse.get_pos()  and Rect.collidepoint(x,y)That's exactly what I do for my menu code. If you don't mind wadingthrough a more-or-less complete game, you can see my main menu code here:http://www.bigdicegames.com/Woody/BDG_07_04.zipLook at stateMainMenu.py which is a menu (a couple of buttons), and thenthere's stateNewGameMenu.py and stateOptions.py which look like modaldialog boxes, but operate the same way.The function in stateMainMenu.py to look at is 
"handleMouseButton" on line165, which iterates over the buttons, and checks to see if the user hasclicked inside the widget, and if so, calls a method on the widget.It's not a tutorial, but it might be useful.-Dave LeCompte

_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!