Skip to main content

A popup manager for pygame

Project description

Pygame Popup Manager

Pygame Popup Manage 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 most easy way to install this package is to do it with pip:

pip install pygame-popup

Use

First, don't forget to call pygamepopu.init function right after having call 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 instanciate 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(my_custom_menu)

If you want more code illustrations, check the examples/minimal_main_menu.py module

Customization

Unfortunately, the customization is limited for the moment.

But you can still provide your own graphical assets to the components, as you can see in the screenshot below.

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!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygame-popup-0.0.2.tar.gz (24.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygame_popup-0.0.2-py3-none-any.whl (28.7 kB view details)

Uploaded Python 3

File details

Details for the file pygame-popup-0.0.2.tar.gz.

File metadata

  • Download URL: pygame-popup-0.0.2.tar.gz
  • Upload date:
  • Size: 24.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.6

File hashes

Hashes for pygame-popup-0.0.2.tar.gz
Algorithm Hash digest
SHA256 24dfc5188ac9d247138624302c3a076eb32e6a5fabfc4a800c405fd8e249c2fa
MD5 003659aae95a123afccf9f3165e8a09f
BLAKE2b-256 fcb066990b22a51efe71dc32b762246e882d875d7975f181beb8e9377c099978

See more details on using hashes here.

File details

Details for the file pygame_popup-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pygame_popup-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 28.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.6

File hashes

Hashes for pygame_popup-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c93f3bf42aeb232200cce90dd45aaede077d86209b6a2bba800b82c3817aca80
MD5 d6bddf3020192df42a99f7549ec0933e
BLAKE2b-256 dfdf48bfbd39d5d186d4e760ce8c6f8414b2a61e5bd4480710a5234b22776f97

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page