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.
Pyvidplayer - An extremely easy to use module that plays videos on Pygame

pyvidplayer An extremely easy to use module that plays videos on Pygame Example

null 17 Dec 5, 2022
A module for use with Pygame. Includes fully customisable buttons, textboxes, sliders and many more, as well as the ability to create and run animations on these widgets.

Pygame Widgets A helper module for common widgets that may be required in developing applications with Pygame. It supports fully customisable buttons,

null 37 Jan 2, 2023
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 8, 2022
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
This is a simple game made using pygame.

Ball breaker This is a simple game made using pygame game view The game view have been updated wait for the new view to be uploaded Game_show.mp4 Lear

Rishikesh Kumar 3 Nov 5, 2021
A simple matrix code rain created using Python with Pygame.

Matrix4_code_rain A simple matrix code rain created using Python with Pygame. To run the code you will need Pygame and MS Mincho font. Create a projec

null 7 Nov 6, 2022
Simple car game written in PyGame

Welcome to CarGame ?? Car Game written in PyGame! NOTE: This is still new and there may be stuff broken... ?? Homepage Install install pygame by typin

John 1 Oct 29, 2021
Racing Fire - A simple game made with pygame.

Racing Fire A simple game in the making. Using pygame, this game is made to feel like an old arcade game. I developed a simple controller for it with

Builder212 1 Nov 9, 2021
A simple pygame implementation of the LOGO programming language.

LOGO-py A simple pygame implementation of the LOGO programming language. Latest Version Notes Fixed a bug where penup/pendown would not work properly.

Ethan Evans 1 Dec 5, 2021
A Simple Scissor Paper Rock Game On Python Using Pygame.

Scissor Paper Stone Game Using Pygame This is a simple GUI based game made on pygame python. Installation Run code on your machine: git clone https:

Dipin Adhikari 0 Mar 21, 2022
Simple Game created using Python & PyGame, as my Beginner Python Project!

Space Invaders This is a simple SPACE INVADER game create using PYGAME whihc have sound and lot's of keyboard functions. Prerequisites More Experience

Gaurav Pandey 2 Jan 8, 2022
null 3 Oct 22, 2021
learn and have fun developing 2D retro games using python and pygame

Retro 2D Game Development Using Python + PyGame Skill up your programming skills with a walk down the memory lane. Learn how to create a retro 2D game

Marvin Trilles 1 Feb 23, 2022
Quiz game made entirely with python and pygame for school work

Tabela de conteúdo Descrição Como instalar Linguagens usadas Contribuidores Créditos Problemas com o jogo? Contate-nos Descrição Quiz feito inteiramen

null 3 Apr 12, 2022
FlappyBird game with python and pygame

FlappyBird game with python and pygame

Mohammad Dori 4 Jul 15, 2022
Made by Ashish and Avinash-sord12k. Powered by pygame

Spook_alle About -Made by Ashish (Github: Ashish-Github193) and Avinash-sord12k Version - BETA v_1.0 /1-11-2021/ (game is at its base version more ite

Ashish Kumar Jha 1 Nov 1, 2021
This is a 2D Link to the Past-esque game made using Python 3.2.5 and pygame 1.9.2

Queen-s-Demise Queen's Demise This is a 2D Link to the Past-esque game made using Python 3.2.5 and pygame 1.9.2 I made this for a game development cla

Zoey 1 Dec 15, 2021
pygame is a Free and Open Source python programming language library for making multimedia applications like games built on top of the excellent SDL library. C, Python, Native, OpenGL.

pygame is a Free and Open Source python programming language library for making multimedia applications like games built on top of the excellent SDL library. C, Python, Native, OpenGL.

pygame 5.6k Jan 1, 2023
Made with pygame. Multiplayer game using socket module and threading.

Rock Paper Scissor made with python-pygame. Poorly made, as a beginner in programming. Multiplayer with server code and client code provided.

AllenJo 1 Dec 29, 2021