Gallery / Examples
Several examples are provided with the pygame_menu
library. To run the
examples, simply execute these commands in a terminal:
$> python3 -m pygame_menu.examples.game_selector
$> python3 -m pygame_menu.examples.multi_input
$> python3 -m pygame_menu.examples.scroll_menu
$> python3 -m pygame_menu.examples.simple
$> python3 -m pygame_menu.examples.timer_clock
Other examples that show specific use cases of the menu are also provided:
$> python3 -m pygame_menu.examples.other.calculator
$> python3 -m pygame_menu.examples.other.dynamic_button_append
$> python3 -m pygame_menu.examples.other.dynamic_widget_update
$> python3 -m pygame_menu.examples.other.image_background
$> python3 -m pygame_menu.examples.other.scrollbar
$> python3 -m pygame_menu.examples.other.scrollbar_area
$> python3 -m pygame_menu.examples.other.ui_solar_system
Them can also be imported as follows:
from pygame_menu.examples.example import main
main()
Example sources can also be found in the Github repo. Also, check out widget-specific examples in the Adding Widgets documentation page.
Simple example
Source: examples/simple.py
Game selector example
Source: examples/game_selector.py
Multiple input example
Source: examples/multi_input.py
Timer clock example
Source: examples/timer_clock.py
Other - Calculator (Decoration, Events, OOP, Frames)
Source: examples/other/calculator.py