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
$> python3 -m pygame_menu.examples.window_resize
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.maze
$> python3 -m pygame_menu.examples.other.scrollbar
$> python3 -m pygame_menu.examples.other.scrollbar_area
$> python3 -m pygame_menu.examples.other.ui_solar_system
$> python3 -m pygame_menu.examples.other.widget_positioning
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.
Game selector example
Source: examples/game_selector.py
Multiple input example
Source: examples/multi_input.py
Simple example
Source: examples/simple.py
Timer clock example
Source: examples/timer_clock.py
Window resize example
Source: examples/window_resize.py
Other - Calculator (Decoration, Events, OOP, Frames)
Source: examples/other/calculator.py
Other - Dynamic widget update (OOP style)
Other - Image background
Other - Maze Pathfinder (GUI)
Source: examples/other/maze.py