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.
シューティングゲームぽい?未完成ですけど

シューティングゲームぽい?未完成ですけど

kawamineka 64 Jun 25, 2022
Pratice Project - Tic tac toe game

Hello! This tic-tac-toe game project and its notes are result from a course pratice milestone. The project itself is written in Python using the Jupyt

Rafael Nascimento 1 Jan 07, 2022
Rock Paper Scissors Game with PyQt5

Rock-Paper-Scissors-Game rock paper scissors is a old game that all of us played it but this time let's play with computer Description This is Rock Pa

MohammadAli.HBA 4 Nov 11, 2021
Rudimentary CMD based implementation of the Tic Tac Toe game

Packages used: questionary random os (Requires Python 3.8 as walrus operators are used in the script) Contains the .py file (tictactoe.py) and an exe

Ashwin 1 Oct 15, 2021
Made to help you create UI using pygame in python, gonna add way more to this project

Pygame visualizer Made to help you create UI using pygame in python, gonna add way more to this project. As of now, this is only hours worth of work.

Ayza 2 Feb 08, 2022
A shooter game.

Screenshots Installation GNU/Linux Go to the Releases tab. Download InfiniteShooter.flatpak from the latest version of InfiniteShooter Open the termin

PastThePixels 13 Dec 01, 2022
made a life sim game because i was tired of a astray gamedev company, everything here is open-source

Srel made a life sim game because i was tired of a astray gamedev company, everything here is open-source Progress Currently making the cmd-line versi

2 Nov 14, 2021
A bot that deletes any embeds sent by a tropical webhook containing hex #000000 rancher's boots

tropical-webhook-cleanup how to use download the source code as zip get your discord bot token from https://discord.com/developers/applications put yo

carreb 0 Nov 25, 2022
Synthesizer based on Conway's Game of Life

Conway Synth Synthesizer based on Conway's Game of Life Trying to avoid step sequencer fashions that have been done before and basing it on actual cel

Giacomo Loparco 4 Mar 15, 2022
This is game 2048 created with moudle of python tkinter and OOP.

Game 2048 This is game 2048 created with moudle of python tkinter and OOP. This game build on classes. For start this game run: If you have python ver

0 Nov 02, 2021
Pokemon game made in Python with open ended requirements from Codecademy

Pokemon game made in Python with open ended requirements from Codecademy. This is one of my first projects utilizing OOP and classes! -This game is a

Kevin Guerrero 2 Dec 29, 2021
A simple hangman game for beginners trying to learn python

Hangman Game This is a simple hangman game for beginners trying to learn python. I have tried to keep it as simply as possible. Sample output Here is

1 Oct 13, 2021
HackNC 2021 Project

pyTunes HackNC 2021 Project Setting Up Once the repo is cloned, install the requirements through pip install -r ./requirements.txt Once that is done,

Demo 1 Nov 07, 2021
Open source Brawl Stars server emulator for version 29 of the game!

Welcome to Classic-Brawl v29 Remake 👋 Open source Brawl Stars server emulator for version 29 of the game! (Remake) What's working ? Battles Trophies

CrossFire 4 Jan 19, 2022
Space Invaders x Asteroid Game

Retro Journey 1: Space Invaders A simple implementation of a retro style video game where users compete against asteroids and the goal is to destroy a

Sandesh Lamsal 2 Aug 05, 2022
A car learns to drive in a small 2D environment using the NEAT-Algorithm with Pygame

Self-driving-car-with-Pygame A car learns to drive in a small 2D environment using the NEAT-Algorithm with Pygame Description A car has 5 sensors ("ey

Henri 3 Feb 01, 2022
Wordle - Implementation of wordle and a solver

Wordle - Implementation of wordle and a solver

Kurt Neufeld 1 Feb 04, 2022
BUG OUTBREAK is a game of adventure and shooting.

BUG OUTBREAK BUG OUTBREAK is a game of adventure and shooting. I am building the game for Github Game Off 2021. This game has 5 levels. You have to co

Shreejan Dolai 3 Nov 11, 2022
Typing Game : from nob to good

Fast and Curious A game to learn/improve keyboard typing skills. The main idea is to improve your typing skills and at the same time learn fun facts (

Raffaele Fiorillo 7 Jun 13, 2022
Guess number game with PyQt5

Guess-Number-Project Guess number game with PyQt5 you can choose a number in your mind and then computer will guess a nummber and you guide the comput

MohammadAli.HBA 1 Nov 11, 2021