The easiest way to install this package is to do it with pip:
(.venv) $ pip install pygame-popup
The whole system is working around the
MenuManager class that is the controller of all the popups in background and in foreground.
An unique instance per scene/window has to be created and the pygame screen on which the popups will appear should be provided, like this:
from pygamepopup.menu_manager import MenuManager screen = pygame.display.set_mode(WINDOW_SIZE) menu_manager = MenuManager(screen)
To open a new popup menu, you should first create it by instantiate the
The components that should be in the menu should be provided.
Next, don’t forget to call the
open_menu method of the menu manager to notify it about the new menu.
For example, the following code will open a popup with a “do-nothing” button and a close button (added by default by the
from pygamepopup.components import Button, InfoBox my_custom_menu = InfoBox( "Title of the Menu", [ Button( title="Hello World!", callback=lambda: None ) ] ) menu_manager.open_menu(my_custom_menu)
If you want more code illustrations, go check out the Examples.