A menu for pygame. Simple, and easy to use

Overview

pygame-menu

@ppizarror License MIT Python 3.6+ Pygame 1.9.3+/2.0+ PyPi package Build status Total alerts Language grade: Python Codecov FOSSA Status Open issues PyPi downloads Total downloads Buy me a Ko-fi

Source repo on GitHub, and run it on Repl.it

Introduction

Pygame-menu is a python-pygame library for creating menus and GUIs. It supports several widgets, such as buttons, color inputs, clock objects, drop selectors, frames, images, labels, selectors, tables, text inputs, color switches, and many more, with multiple options to customize.

Comprehensive documentation for the latest version is available at https://pygame-menu.readthedocs.io

Install Instructions

Pygame-menu can be installed via pip. Simply run:

$> pip install pygame-menu -U

To build the documentation from a Git repository:

cd docs $> make html">
$> clone https://github.com/ppizarror/pygame-menu
$> cd pygame-menu
$> pip install -e ."[docs]"
$> cd docs
$> make html
Comments
  • Make Menu running as other GUI elements

    Make Menu running as other GUI elements

    To be consistent with any other widgets, GUI elements:

    • the Menu._main should be rename to Menu.update
    • the Menu.draw should take surface as argument
    • the Menu.mainloop should take the surface, and bgfun arguments (remove them from Menu constructor)
    • the _dopause attribute can be trashed

    This is to ease the use of the menu, with less parameters in the Menu constructor. But only a proposition, of course ;-). It's imply lots of changes.

    Thus 2 scenario for the end user:

    1. Let's pygame-menu do the event loop:

    
    def draw_background():
        ...
    
    mymenu = Menu(...)
    
    mymenu.mainloop(surface, bgfun=draw_background)
    

    2. User's application manage the event loop:

    
    def draw_background():
        ...
    
    mymenu = Menu(...)
    
    While True:
        draw_background()
    
        events = pygame.event.get()
        for event in events:
            if event.type == pygame.QUIT:
                exit()
    
        mymenu.update(events)
    
        mymenu.draw(surface)
    
        pygame.display.update()
    
    enhancement 
    opened by anxuae 27
  • Integrate themes

    Integrate themes

    As discussed in #162 this PR integrate themes for pygame. This makes a lot of changes, from the Menu constructor to widgets. Also examples were updated.

    Added ".copy()" feature to Themes, because each theme object must be different for each menus.

    opened by ppizarror 21
  • Text input & all is widget

    Text input & all is widget

    Hi,

    After some weeks, I finally found the time to make this PR.

    Concerning your previous remarks about #8 :

    1. The backspace button is now disabled

    2. The "word ellipsis" on too long text input is not yet implemented, I will propose it in another PR (because not enough time for the moment)

    3. Events from navigation are ignored on a text input

    General remark about the rework that I have performed:

    1. All elements of a menu are now a widget. This implies more custom classes and objects, but it gives the advantage of:

    a. Avoid managing all events in the same function (each widget has its own update() method) b. Going in the way of #18 c. Widget position can be moved easily, it will be easier to implement #15 in the future

    1. A new attribute _top has been added to keep reference to the top level menu. However, I think that the management of change between menu (open/close) is quite difficult to manage with the current code (for instance when we need to use the _actualattribute?). Maybe a handler class can be developed to manage the changes between menus.

    Callback management

    I have standardize the way to call the callback function. All widget that can receive/change their values (implements the get_value() method) automatically provide the current value to the onreturn and onchange callback as first argument. This change imply breaking the compatibility with previous version of pygame-menu. Managing callback in such a way, permits to keep constancy between function signature. I let you decide if this is acceptable for the version 2.0.

    Fill free to update/change anything.

    anxuae

    opened by anxuae 19
  • Adding

    Adding "input text" option?

    A input text option to menu would be nice, but i don't know how to gather all keyboard events without "event crash" with the main menu, maybe using a inner mainloop to gather events should work.

    enhancement 
    opened by ppizarror 19
  • Error with custom theme submenus when using pygame_menu.baseimage.BaseImage

    Error with custom theme submenus when using pygame_menu.baseimage.BaseImage

    When I am making a custom theme from an existing theme and use background.color with pygame_menu.baseimage.BaseImage to set a custom image as menu background the image appears fine but if I go into a submenu then back into the main menu the submenu bar does not disappear.

    image

    image

    image

    bug 
    opened by LukePrior 18
  • Error in widget.py : AttributeError: 'Event' object has no attribute 'gain'

    Error in widget.py : AttributeError: 'Event' object has no attribute 'gain'

    Environment information Describe your environment information, such as:

    • SO: Windows 10
    • python version: v3.10.1
    • pygame version: v2.1.2
    • pygame-menu version: 4.2

    Describe the bug Hi,

    I just started to design a game in python based on PyGame and Pygame-menu.

    When I try to execute the simple.py example, I get this error that I can't explain to myself:

    Hello from the pygame community. https://www.pygame.org/contribute.html
    pygame-menu 4.2.0
    Traceback (most recent call last):
      File "d:\User\Dougdoug\Projects\reallybasicpong\main.py", line 50, in <module>
        menu.mainloop(surface)
      File "D:\Software developmentPython\lib\site-packages\pygame_menu.py", line 2910, in mainloop
        self.update(pygame.event.get())
      File "D:\Development softwarePythonlibSite-packagespygame_menu.py", line 2439, in update
        selected_widget.update(events):
      File "D:\Development softwarePython\lib\site-packages\pygame_menu\widgets\widget\textinput.py", line 1570, in update
        self._check_mouseover(event, rect)
      File "D:\Software developmentPython\lib\site-packages\pygame_menu\widgets\core\widget.py", line 692, in _check_mouseover
        if event.gain == 1:
    AttributeError: 'Event' object has no attribute 'gain'
    
    

    On the other hand, I manage to execute correctly the other examples present on the repo without problems.

    Any idea ?

    Thanking you in advance.

    bug 
    opened by DougOne 17
  • Access all widgets in a menu

    Access all widgets in a menu

    Currently it's not possible (without a warning) to iterate through all widgets in a menu, because _widgets is a private attribute in the class Menu. Adding a property fixes this problem:

    @property
    def widgets(self):
    return self._widgets
    

    I guess this was done on purpose, but why? I'd like the option to access all widgets that my menu contains (e.g. to insert a widget at a specific place in the menu).

    enhancement 
    opened by AlcuZan 15
  • Blinking arrow

    Blinking arrow

    Now that we have the arrows working, another functionality I'd like to add is to make the arrows blink, if so desired by the user. Here's my end goal:

    Blinking arrow

    enhancement 
    opened by eforgacs 15
  • Add a menu border as part of the theme

    Add a menu border as part of the theme

    Is your feature request related to a problem? Please describe. I am trying to define a menu with a border, as in this example:

    bildo

    The borders are defined in this file:

    dialog-borders01

    Describe the solution you'd like I would want to be able to define a border for the menu, so that pygame-menu is able to tile it (as opposed to stretching it) and place the corners appropriately. Ideally this option could be made part of a theme.

    Describe alternatives you've considered I tried defining that as a background image, but then I would need to define it with the right final dimensions or it would be stretched. I also tried using menu.get_scrollarea().get_decorator().add_callable, achieving the image above. The problem with this solution is that I cannot define that in a theme, forcing me to modify each menu separatedly or to create a subclass of Menu that applies this by default.

    enhancement 
    opened by vnmabus 14
  • Possible to have two columns?

    Possible to have two columns?

    Any idea what would be required to make it possible to have two columns of items in a menu? I see that there's a "left" and "right" direction, so maybe this was an intended feature?

    I'm glad to help implement it.

    enhancement 
    opened by wrybread 13
  • Scrollbar in general not working with touchscreen

    Scrollbar in general not working with touchscreen

    Environment information Describe your environment information, such as:

    • SO: linux/Raspberry OS
    • python version: v3.7
    • pygame version: v2.0.1
    • pygame-menu version: v4.0.7-master

    Describe the bug Scroll bar doesn't respond to touch on the screen. I can't drag the slider from the scroll bar. At some point I try to touch lower in the scroll bar to see if at least I can go down not dragging but jumping to the lower section (I don't know if this make sense), but it also doesn't work. Same test in the computer with the mouse works perfectly. When I try to slide the scroll bar, it seems to gets selected because it changes color, but nothing happen.

    To Reproduce I copied the scroll_menu example and added touchscreen=True in all menus. The result is I can select buttons, go inside other menu and go back with the X, but scroll bar doesn't respond to touchs. video2

    bug 
    opened by yagui 12
Releases(4.3.4)
Owner
Pablo Pizarro R.
I love coding... who doesn't @ Github? :trollface:
Pablo Pizarro R.
XPlaneROS is a ROS wrapper for the XPlane-11 flight simulator.

XPlaneROS XPlaneROS is a ROS wrapper for the XPlane-11 flight simulator. The wrapper provides functionality for extracting aircraft data from the simu

AirLab Stacks 26 Dec 04, 2022
Client-Server design (guess the closest number to the average score game)

Multiplayer game (enter the number closest to the average) Design Client-Server design The client's side is responsible for sending numbers from the g

Adam Piszczek 0 Jun 29, 2022
Building a Mario-like, classic platformer game in Python using the PyGame Library

Building a Mario-like, classic platformer game in Python using the PyGame Library

Clarence Vinzcent Reyes 1 Feb 06, 2022
A stat tracker for the bedwars hypixel game in python

A hypixel bedwars stat tracker. Features Get stats in your current lobby Get stats in a guild Installation & Configuration git clone https://github.co

Le_Grand_Mannitout 3 Dec 25, 2021
A little python script for finding the best word choice in a Wordle game

A little python script for finding the best word choice in a Wordle game, by assuming that at each step you want to minimise the average number of possible answers left after guessing that word (note

zeb 26 Mar 16, 2022
j-chess implementation in python

j-chess-client-python This repository aims to be a starting point for implementing a chess ai for the j-chess-server in python. To start, you can copy

Jonas 1 Dec 25, 2021
An interactive pygame implementation of quadtree spatial quantization

QuadTree-py An interactive pygame implementation of quadtree spatial quantization Contents Installation Usage API Reference TODO Installation Clone th

Ethan 1 Dec 05, 2021
Wordle-Python - A simple low-key clone of the popular game WORDLE made with python and a 2D Graphics module Pygame

Wordle-Python A simple low-key clone of the popular game WORDLE made with python

Showmick Kar 7 Feb 10, 2022
For the Exapunk minigame, ПАСЬЯНС

Exapunks Automation This repository solves Exapunk's Solitaire minigame, ПАСЬЯНС. This repository is useable, but only with specific display condition

Will C 5 Jul 29, 2022
3 Oct 22, 2021
A small fun project to simulate Conway's Game of Life, created in Python.

A small fun project to simulate Conway's Game of Life, created in Python. Conway's Game of Life simulates a grid of cells, where the state of each cell consists of whether the cell is alive or dead.

Harrison Verrios 1 Jun 19, 2022
uses Entropy to find the best next guess for Wordle, given the color clues

WordleSolver uses Entropy to find the best next guess for Wordle, given the color clues use player.py and enter in the string for the suggested clue w

Steve Earth 1 Jan 26, 2022
Deliver buycraft orders to players across the map in minecraft servers using baritone

Deliver buycraft orders to players across the map in minecraft servers using baritone

synthels 1 Nov 14, 2021
Implementation of the famous puzle Tower of Hanoi

Tower_of_Hanoi Implementation of the famous puzle "Tower of Hanoi". The setup consists of three pegs (sticks) and a certain amount of discs (in this i

Raffaele Fiorillo 3 Mar 08, 2022
Wordle - Implementation of wordle and a solver

Wordle - Implementation of wordle and a solver

Kurt Neufeld 1 Feb 04, 2022
A Cataclysm: Dark Days Ahead launcher with additional features

CDDA Game Launcher A Cataclysm: Dark Days Ahead launcher with additional features. Download here. Implemented features Launching the game Detecting th

Rémy Roy 402 Jan 02, 2023
An old time game Tic-Tac-toe

A Tic Tac Toe Bot This is the code repository for my article on Medium - Playing Games with Python - Tic Tac Toe, where I have tried to take the famou

Jigyanshu 0 Feb 25, 2022
Software Design | Spring 2020 | Classic Arcade Game

Breakout Software Design Final Project, Spring 2020 Team members: Izumi, Lilo For our Interactive Visualization, we implemented the classic arcade gam

Lilo Heinrich 1 Jul 26, 2022
Email guesser - Guessing BF email based on emailGuesser by WhiteHatInspector

email_guesser Guessing BF email based on emailGuesser by WhiteHatInspector (http

4 Dec 25, 2022
A small, Pygame-based library project intended for personal use.

EzyGame Version 0.0.1 A simple library project intended for personal use with Pygame. Warning: I am a very amateur programmer, so the code will probab

Dorbell 1 Jan 08, 2022