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

Re: [pygame] Question about Pygame-menu package





On Sun, Sep 23, 2018 at 10:03 PM Daniel Foerster <pydsigner@xxxxxxxxx> wrote:
The way to find out what item is selected is to use a different function for different menu items. This seems to be callback driven.

Thanks, got that one.  

How do you close a menu? I'm honestly not sure why your example doesn't work as expected. I downloaded and ran the example successfully, but no amount of tweaking to your application worked for me. My honest suggestion would be to find a different menu library; this one seems to have a number of other issues, including throwing a NameError whenever the menu tries to quit pygame.

I noticed that error too, easily fixed (add "_" to pygame in every call to pygame.exit() ), but I agree, it's a warning sign about the library in general. It's pretty much perfect for my needs though, so I'm hoping there's an easy fix that enables simply closing a menu when an item is selected.

Or if anyone happens to know of another menu library, one that ideally:

- allows for menus to be easily opened and closed

- allows more than one column of menu items

- allows for graphical elements in the menu items

I'd love to hear about it. 












On Sun, Sep 23, 2018 at 11:10 PM Alec Bennett <wrybread@xxxxxxxxx> wrote:
I'm trying to add the beautiful menus from Pygame-menu (https://github.com/ppizarror/pygame-menu) to my project, but having trouble. In my attached stripped down sample, I'm trying to show menu1 when the 1 key is pressed, and show menu2 when the 2 key is pressed. They're both "main menus" launched from the root of the app, as opposed to one being a submenu of the other.

My questions:

- how can I find out what item was selected in the menu? Clicking a selection triggers the item_selected() function, but doesn't send any info about which item was selected.

- how can I close a menu? Running menu1.disable() in item_selected() doesn't close the menu... How do I close the menu when something is selected?

Ideally in this sample I'd like to launch menu1 when the 1 key is pressed, choose a selection, print info about what was selected, and return to the root of the app. Then pressing keyboard 2 launches menu2, repeating the process.

Thanks for any help, and apologies if I'm missing something obvious here.