Git Product home page Git Product logo

Comments (5)

bluefish2020 avatar bluefish2020 commented on June 11, 2024 2

Calling pygame.event.clear() after your play loop has exited seems to make it behave like you are expecting:

        def start_playing():
            Gameplay().play()
            pygame.event.clear()  # Prevent menu from seeing pygame.QUIT
            self.configure_window()  # This is needed to return menu's size and caption

That lets the menu's internal loop resume without exiting.

I haven't driven the game menus using menu.mainloop() in my project so there might be another approach I am oblivious of.

from pygame-menu.

ppizarror avatar ppizarror commented on June 11, 2024 1

Hello, can you provide a minimal working example to test this bug? Thanks

from pygame-menu.

leestarb avatar leestarb commented on June 11, 2024

Hello, can you provide a minimal working example to test this bug? Thanks

Hello, dear ppizarror.

Here is a simple example of the issue:
https://tempfile.io/en/ynBUL0wGEjlVI8g/file
(This file will be deleted after 7 days!)

from pygame-menu.

leestarb avatar leestarb commented on June 11, 2024

Calling pygame.event.clear() after your play loop has exited seems to make it behave like you are expecting:

        def start_playing():
            Gameplay().play()
            pygame.event.clear()  # Prevent menu from seeing pygame.QUIT
            self.configure_window()  # This is needed to return menu's size and caption

That lets the menu's internal loop resume without exiting.

I haven't driven the game menus using menu.mainloop() in my project so there might be another approach I am oblivious of.

Thanks! That is right direction.
I'm investigating the event queue. Looks like it is a bug of pygame.

from pygame-menu.

leestarb avatar leestarb commented on June 11, 2024

I started using pygame.event.get(pygame.QUIT) to check for quitting. Instead of this (as I used before) I should iterate over pygame.event.get() and check whether there is event with type pygame.QUIT. This solves the issue.

But also, using pygame.event.get(pygame.QUIT) and adding below pygame.event.clear() or pygame.event.get() works.

Not sure why this happens. That requires more investigation to understand the nature of this. At least, for me, the issue is solved.

Thank you for help, @bluefish2020 ! =)

from pygame-menu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.