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.
Snake - Code for "Deep Snake for Real-Time Instance Segmentation" CVPR 2020 oral

Good news! Snake algorithms exhibit state-of-the-art performances on COCO dataset: DANCE Deep Snake for Real-Time Instance Segmentation Deep Snake for

ZJU3DV 1.1k Dec 26, 2022
Pendulum Simulation using Pygame

Pendulum project, built using pygame and math modules.

3 Nov 09, 2021
This is a simple Tic Tac Toe game built with Python.

This is a simple Tic Tac Toe game built with Python.

⚝αикιт кυмαя⚝ 6 Sep 01, 2022
A Minecraft clone written in python and pyglet.

PyCraft A Minecraft clone written in python and pyglet. Running PyCraft To run PyCraft, run the following code: git clone https://github.com/TheWebCra

The WebCrafters 17 Dec 29, 2022
A set of tools to help you with running a Project Zomboid game server (Linux only)

Project Zomboid Server Tools A set of tools to help you with running a Project Zomboid game server (Linux only). Features Install Project Zomboid Dedi

24 Dec 25, 2022
Wordle-helper: python script to help solving wordle game

wordle-helper This is a python script to help solving wordle game 5-letter-word-

MD Nur Ahmed 2 Feb 08, 2022
A full featured game of falling pieces using python's pygame library.

A full featured game of falling shapes using python's pygame library. Key Features • How To Play • Download • Contributing • License Key Features Sing

Giovani Rodriguez 7 Dec 14, 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 08, 2022
Wordle - Implementation of wordle and a solver

Wordle - Implementation of wordle and a solver

Kurt Neufeld 1 Feb 04, 2022
A "finish the lyrics" game using Spotify, YouTube Transcript, and YouTube Search APIs, coupled with visual machine learning

Singify Introducing Singify, the party game! Challenge your friend to who knows songs better. Play random songs from your very own Spotify playlist an

Josh Wong 4 Nov 19, 2021
AI that plays Flappy Bird Game using the python module NEAT.

Flappy Bird AI [NEAT] AI that plays Flappy Bird Game using the python module NEAT. Instructions Install Python Modules: pip3 install -r requirements.t

Abhisht 5 Jan 26, 2022
Jiminy, fast and portable Python/C++ simulator of poly-articulated systems with OpenAI Gym interface for reinforcement learning.

Jiminy is a fast and portable cross-platform open-source simulator for poly-articulated systems. It was built with two ideas in mind: provide a fast y

Alexis DUBURCQ 122 Dec 29, 2022
linorobot2 is a ROS2 port of the linorobot package

linorobot2 is a ROS2 port of the linorobot package. If you're planning to build your own custom ROS2 robot (2WD, 4WD, Mecanum Drive) using accessible parts, then this package is for you. This reposit

linorobot 195 Dec 29, 2022
An optimal solution finder for the game Wordle, written in Python

wordle-solver: a nearly-optimal computer player for Wordle Wordle is an interesting word guessing game. This program plays it very well, taking only 3

4 Jun 13, 2022
A very bad wordle solver to help me solve the daily wordle

Wordle Solver A very bad wordle solver to help me solve the daily wordle on https://www.powerlanguage.co.uk/wordle/ TODO list take into account letter

Logan Anderson 4 Feb 03, 2022
Graphical impimetaion of Conway's Game of Life in Python using pyglet

Conway's Game of Life in Python Konstantin Opora Conway's Game of Life: graphical implementation in python using pyglet. developed in Python 3.10.0 Re

Konstantin Opora 1 Nov 30, 2021
Flappy Bird hack using Deep Reinforcement Learning (Deep Q-learning).

Using Deep Q-Network to Learn How To Play Flappy Bird 7 mins version: DQN for flappy bird Overview This project follows the description of the Deep Q

Yen-Chen Lin 6.4k Dec 30, 2022
Repository for the diana chess competition. AI Lecture 21/22

Notes for Assignment 8 (Chess AI) We recommend using an IDE (like Pycharm) for working on this assignment. IMPORTANT: Please make sure you use python

Cognitive Systems Research Group 3 Jan 15, 2022
Algorithm to solve Wordle correctly 100% of the time within 6 attempts.

WordleSolver © Zulkarnine, 2022. Algorithm to solve Wordle 100% of the time within 6 attempts. You can go ahead and run main.py to run it for all 2315

Zulkarnine Mahmud 69 Dec 11, 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