Skip to main content

Pygame Popup Manager

made-with-python dl-pypi license version

Docs are now available at: https://pygame-popup-manager.readthedocs.io/en/latest/

Pygame Popup Manager is a very small engine permitting to easily build all kind of popup in a pygame project.

Here is an example of basic menus that could be created with this manager:

Main menu with side menu

Installation

The easiest way to install this package is to do it with pip:

pip install pygame-popup

Use

First, don't forget to call pygamepopup.init function right after calling pygame.init function.

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

menu_manager = MenuManager(screen)

The display, motion and click methods of this class should be called in the application main loop in order to notify the manager of any pygame event.

To open a new popup menu, you should first create it by instantiate the InfoBox class. 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 InfoBox)

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, check the examples/minimal_main_menu.py module.

Customization

The default graphics resources can be easily changed by your own by simply calling certain methods of the configuration module, wherever you want, as can be seen below.

import pygamepopup

pygamepopup.configuration.set_button_background("sprites/inactive_button.png",
                                                "sprites/active_button.png")
pygamepopup.configuration.set_dynamic_button_background("sprites/inactive_button.png",
                                                        "sprites/active_button.png")
pygamepopup.configuration.set_info_box_background("sprites/menu_box.png")

It is also possible to directly provide an asset to a specific component, if you want a button to be different from others for example.

Button(
    title="Hello World!",
    callback=lambda: None,
    sprite=pygame.image.load("sprites/different_button.png"),
    sprite_hover=pygame.image.load("sprites/different_button_hover.png")
)

With this kind of configuration you can made an interface similar to this one:

Options menu with assets

Contact

You can contact me directly by e-mail if you have any question regarding the package. Also, I will be really happy to know you are using this package, so don't hesitate to share me the link to your project if you tried something!

For suggestions or bugs, please create an issue in the GitHub repository: https://github.com/Grimmys/pygame_popup_manager/issues

Thanks!

Metadata

Release files for pygame-popup 0.11.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pygame-popup 0.11.2
File Size Uploaded
pygame_popup-0.11.2.tar.gz 28.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pygame-popup 0.11.2
File Interpreter ABI Platform
pygame_popup-0.11.2-py3-none-any.whl Python 3 none any Details

Total release size: 63.6 kB

Release files / pygame_popup-0.11.2.tar.gz

Download URL pygame_popup-0.11.2.tar.gz
Size 28.3 kB
Tags Source
SHA-256 checksum
How to use checksums
55c252740381b07c673b5f18cbb958ae890b62cae7942bf347f6da6bcb7fab8b
BLAKE2b-256 checksum
How to use checksums
0c281aca98a6bd47cf6f3614f72d853bc127c493769c50eec956fb7bf9527857
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / pygame_popup-0.11.2-py3-none-any.whl

Download URL pygame_popup-0.11.2-py3-none-any.whl
Size 35.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
90e55438e6ce664b58372e8f599ebf5e8ff6bd3a3eb6401416d8ae10dec8a8c0
BLAKE2b-256 checksum
How to use checksums
ae6e11541c9ba384dbf50b9b5ab75e7aeaf55927b16426da53607724a7775592
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

0.11.2 This release

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page