If the menu is disabled, .mainloop() is a no-op. No point in rebuilding
existing functionality.

On Mon, Sep 24, 2018, 07:26 Luke Paireepinart <rabidpoob...@gmail.com>
wrote:

> Maybe I'm missing something here, but why are you calling the mainloop of
> each menu every iteration? It seems like if you only called the mainloop
> for the active menu, there would be no need to disable or cancel the menu.
>
> You could just have a single menu object assigned to None. Then if they
> hit 1 or 2, call methods that create and return the menu and set to menu.
> In your loop you can say if menu is not None: menu.mainloop(events). Then
> in your event delegate, if you want to close the menu, just set menu back
> to None and re render your background UI.
>
> You may also want to consider what events you should delegate to the menu
> and which you should capture for yourself. Eg. You may want to prefilter
> the events and handle the pygame.quit event yourself.
>
> On Mon, Sep 24, 2018, 1:59 AM Alec Bennett <wrybr...@gmail.com> wrote:
>
>> Sorry for the cross post, I posted an issue to the project's github page
>> here:
>>
>> https://github.com/ppizarror/pygame-menu/issues/19
>>
>> For anyone interested, note the fix I posted there. Feedback invited.
>>
>>
>>
>> On Sun, Sep 23, 2018 at 10:08 PM Alec Bennett <wrybr...@gmail.com> wrote:
>>
>>>
>>>
>>> On Sun, Sep 23, 2018 at 10:03 PM Daniel Foerster <pydsig...@gmail.com>
>>> 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 <wrybr...@gmail.com>
>>>> 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.
>>>>>
>>>>>
>>>>>

Reply via email to