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.
Découvrez CubeCraft Launcher, une application uniquement codé en Python et en Batch

Découvrez CubeCraft Launcher, une application uniquement codé en Python et en Batch. Grâce à son interface graphique facile et intuitive, vous pouvez vous retrouver facilement.

1 May 21, 2022
TetrisAI - Tetris AI Bot using computer vision to play game automatically

Tetris AI Tetris AI Bot using computer vision to play game automatically bot.py

11 Aug 29, 2022
Mastermind-Game - A game to test programming and logical skills

Bem vindo ao jogo Mastermind! O jogo consiste em adivinhar uma senha que será ge

Marcelo Daros 0 Jan 27, 2022
Cocos2d-x is a suite of open-source, cross-platform, game-development tools used by millions of developers all over the world.

cocos2d-x Win32 Others cocos2d-x is a multi-platform framework for building 2d games, interactive books, demos and other graphical applications. It is

cocos2d 16.7k Jan 04, 2023
SnailJumper - A game that is developed as an assignment for Computer Intelligence course

Snail jumper Neuroevolution game assignment. Fall 2021 - Computer Intelligence.

Soroush Mehraban 22 Aug 22, 2022
Blackjack Game made using Python

Blackjack Game made using Python Blackjack is a popular card game played in most of the casino.This is an intuition to replicate the same card game us

SUHASJAGADISH 1 Nov 28, 2021
Backend application for a game to classify waste for recycling

Waste Organizer Game Backend application used in a game to classify trash for recycling. What is waste organizer game? It is a game developed during t

10 Jun 13, 2021
FlappyBird game with python and pygame

FlappyBird game with python and pygame

Mohammad Dori 4 Jul 15, 2022
Ice-Walker-Game - This repository is about the Ice Walker game made in Python.

Ice-Walker-Game Ce dépot contient le jeu Ice Walker programmé en Python. Les différentes grilles du jeu sont contenues dans le sous-dossier datas. Vou

Mohamed Amine SABIL 1 Jan 02, 2022
The game company we work for has two events that we want to track: buy an item and join a guild. Each of them has metadata characteristic of such events.

The game company we work for has two events that we want to track: buy an item and join a guild. Each of them has metadata characteristic of such events.

Caro Arriaga 1 Feb 04, 2022
A python script that uses pygame to display fractals.

Pygame-Fractals A python script that uses pygame to display interactive fractals. There are 3 fractals on the script. They can be displayed on the col

michel 2 Feb 09, 2022
TicTacToc - Simple TicTacToc game played by minimax algorithm

TicTacToc simple TicTacToc game played by minimax algorithm. This app is based o

5 Apr 05, 2022
AI Games and its programming solution with Python.

Problem: Save the princess: Problem defination on Hackerrank: https://www.hackerrank.com/challenges/saveprincess About problem: Princess Peach is trap

Hasit Parmar 1 Feb 19, 2022
Exposè for i3 WM. Fork of https://gitlab.com/d.reis/i3expo to fix crashes and improve features/usability

Overwiew Expo is an simple and straightforward way to get a visual impression of all your current virtual desktops that many compositing window manage

137 Nov 03, 2022
A simple python script to pregenerate minecraft worlds.

mcloady mcloady is a lightweight python script used to pre-generate Minecraft terrain using MCRcon and carpet mod (optional). Inspired by Pre-Generati

5 Dec 08, 2021
Tic-Tac-Toe - Tic-Tac-Toe game build With Python

Tic Tac Toe This game is very popular amongst all of us and even fun to build as

PyLaboratory 0 Feb 06, 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
N-Queens game made using pygame library

N-Queens N-Queens game using pygame for AIML201 Testing: 1. git clone https://github.com/python-game-dev/N-Queens.git 2. cd N-Queens 3. python main.py

1 Sep 24, 2021
A zombie game using Kinetic. You can control players using fingers

This is Eden Park's portpolio: Works, projects and practices This repository can be used to show the potential employers to check my works, code and p

Eden Park 4 May 16, 2022
Utility to find games owned by all (or at least some) of the passed players.

SteamCommonGameFinder Utility to find games that are owned by all (or at least some) of the players you pass into this programm. You can already find

Daniel O'Grady 4 Jan 04, 2022