Giter Site home page Giter Site logo

ppizarror / pygame-menu Goto Github PK

View Code? Open in Web Editor NEW
503.0 16.0 136.0 32.14 MB

A menu for pygame (pygame-ce also supported!). Simple, and easy to use

Home Page: https://pygame-menu.readthedocs.io

License: Other

Python 100.00%
pygame menu pygame-menu python game python-game menus text-input input button

pygame-menu's Introduction

pygame-menu

@ppizarror

License MIT

Python 3.6+

PyPi package

FOSSA Status

Documentation Status

Codecov

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

Note: For pygame-ce, check out pygame-menu-ce.

Install Instructions

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

$> pip install pygame-menu -U

To build the documentation from a Git repository:

$> clone https://github.com/ppizarror/pygame-menu
$> cd pygame-menu
$> pip install -e ."[docs]"
$> cd docs
$> make html

pygame-menu's People

Contributors

anxuae avatar apuly avatar arpruss avatar asierrayk avatar asztalosdani avatar bluefish2020 avatar brenekh avatar da820 avatar dknorad avatar eforgacs avatar i96751414 avatar imgbot[bot] avatar ironsmile avatar joestanky avatar jwllee avatar lgtm-migrator avatar maditnerd avatar mrkprdo avatar notrurs avatar nullp01nt avatar pandaroux8 avatar ppizarror avatar rifqi31 avatar thepeeps191 avatar thisismikekane avatar took avatar vnmabus avatar werdeil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pygame-menu's Issues

Documentation

Hello,
I can't find the documentation.
Can you help me ?

Date input widget

Some ideas:

  • date_format = 'd/m/y'
  • the widget can contain at most 6 "inputs", year, month, day, hour, minute and second
  • with arrow keys the user can select what input they want to fill (mouse handling should work too)

Add more fonts

More open source fonts would be a nice addition for this project

Gamepad/joystick support

Hello! I am experimenting with using your menu library in a small project of mine. I really want to have full gamepad support throughout the game and I am willing to add it to your library. Would you be interested in such a pull request?

draw_region_x=0 overflow

Strange behavior, when draw_region_x=0 and widget_alignment=locals.ALIGN_LEFT, I expect that all widgets are on the left border.

However there is an overflow:

align

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.

How to close a menu when an item is selected?

I can't figure out how to close a menu when an item is selected. If I understand the docs correctly, running menu1.disable() should close menu1, but that's not working for me.

In the attached sample keyboard button 1 makes menu1 appear, and selecting an item should make it disappear since I'm setting menu1.disable(), but nothing happens and the menu stays visible. Interestingly, pressing ESC closes the menu (which is what I want to happen when an item is selected).

And for testing, keyboard button 2 makes menu2 appear.

Any tips on making the menus disappear after an item is selected?

sample.zip

Is there a way remove an option from a menu?

Hey ppizarror, I've been working with your library for a bit now and was wondering if there is a way to remove certain options from a menu. i.e. remove the option "A" once a condition has been met.

I have experimented with menu.clear() followed by menu.add_option("text", menu_name) and so forth but it gives me a "list out of index error" this does indeed let me update the options but they appear in a weird location and cause a runtime error.

Just to give some context, I have made a login menu that logs the user in. Once the user is successfully logged in it returns them to the main menu, but I want to make the option for the login menu to disappear immediately after this.

This is the initial main menu:
image

And this is what it looks like after logging in:
image

I'd love any support and or general guidance. Thanks in advance

Can not post key event to handle menu

Can you tell me what the objective of the function _check_key_pressed_valid() in Menu class?

I'm currently developing on a raspberry-pi and I'm trying to handle menu using physical buttons. When a physical button is pressed, I post the event pygame.event.Event(pygame.KEYDOWN, key=pygame.K_DOWN) , however the function _check_key_pressed_valid() discard it.

Put an image as Background

Hi! this library helped me a lot seriously, but i want to know something for my project, if there is one way to put a image as background on the menu, i would help me a lot.
Thank you very much!

Run without soundcard

Traceback (most recent call last):
File "game_selector.py", line 333, in
main()
File "game_selector.py", line 221, in main
window_width=WINDOW_SIZE[0]
File "/usr/local/lib/python3.7/dist-packages/pygameMenu/menu.py", line 252, in init
self._sounds = _Sound()
File "/usr/local/lib/python3.7/dist-packages/pygameMenu/sound.py", line 132, in init
buffer=buffer)
pygame.error: No available audio device

It will be possible to run this library without sound card?

Can not use BACK key

Hello @ppizarror , I made some tests on the last version 2.0.3, it seems that the BACK don't go to previous menu anymore. This is the same behavior with examples.

Maybe something new to configure in the menu?

Images

Would be cool if you could replace a button text with an image of your own.

Move runtime engine to another class

This is a proposal that comes into my mind because the Menu class becomes bigger.
The Menu class currently implements 2 things:

  • the rendering of the menu itself
  • the runtime engine used to display and process events of the top level menu

It could be possible to move all methods relative to the runtime engine (_main, mainloop, _close, _get_depth, _back, full_reset, _get_actual_index, ...) in a MainMenu class. the Menu class will inherit from it.
Globally all methods dealing with _actual, _prev and _top attributes should be moved in it.

The files mainmenu.py, menu.py and textmenu.py could be moved in a dedicated package pygameMenu/menu.

"Widgets" for pygame-menu

I think that a widgets for pygame-menu would be awesome. Some ideas:

  • Calendar widget
  • In-screen keyboard widget

Assert bgfun as callable rather than types.FunctionType types.MethodType

Problem

Currently, Menu class requires bgfun to be either types.FunctionType or types.MethodType if dopause is True. This excludes other callables, e.g., partial from functools.

Also, it seems that the code only requires bgfun to be callable.

Proposed solution:

Why don't we just make the assertion as callable is True?

Reason:

Things like partial is useful if I were to have a bgfun that can accept a surface as a parameter rather than having it as a global variable.

Support for pygame>=1.9.3

Hello,

I'm working on Raspberry-pi and it seems that the latest packaged version available of pygame is 1.9.3.
I'm wondering if the pined version in the setup.py can be decreased to 1.9.3? (else I'm not able to use pygame-menu on RPI).

Thanks
anxuae

Upload a version on PyPi

Hi

Is it possible to build a version and upload it on PyPi to ease the deployment?
(or maybe it is already done, but I can't find it)

Thanks
anxuae

Create tests

Maybe a test suite would be super useful for this library, considering all the posible? future new features

Valor por defecto de textinput y maxwidth

Hola tengo un error cuando a un text_input trato de asigarle un valor por defecto y al mismo tiempo intento limitar el ancho maximo del mismo usando maxwidth=10

test_menu.add_text_input('Test',textinput_id='id1', maxwidth=10, maxchar=20, default="ABCDEFG")

El error es el siguiente:

Traceback (most recent call last): File "/home/bautista/PycharmProjects/pacman/pacman/dqn/__init__.py", line 185, in <module> test_menu.add_text_input('Holis ',textinput_id='id1', maxwidth=10, maxchar=20, default="ABCDEFG") File "/home/bautista/.local/lib/python3.6/site-packages/pygameMenu/menu.py", line 586, in add_text_input **kwargs) File "/home/bautista/.local/lib/python3.6/site-packages/pygameMenu/widgets/textinput.py", line 262, in __init__ self.set_value(default) File "/home/bautista/.local/lib/python3.6/site-packages/pygameMenu/widgets/textinput.py", line 889, in set_value self._move_cursor_right() File "/home/bautista/.local/lib/python3.6/site-packages/pygameMenu/widgets/textinput.py", line 956, in _move_cursor_right self._update_renderbox(right=1) File "/home/bautista/.local/lib/python3.6/site-packages/pygameMenu/widgets/textinput.py", line 740, in _update_renderbox self._update_maxlimit_renderbox() File "/home/bautista/.local/lib/python3.6/site-packages/pygameMenu/widgets/textinput.py", line 762, in _update_maxlimit_renderbox accum_size += self._keychar_size[char] KeyError: 'A'

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.

AssertionError: Bgfun must be a function (or None if menu does not pause execution of the application)

Hi

I am trying to create a simple menu on my display surface but keep on getting this error.

AssertionError: Bgfun must be a function (or None if menu does not pause execution of the application)

Here is my code.

import pygameMenu

import math, random, sys
import pygame
from pygame.locals import *

exit the program

def events():
for event in pygame.event.get():
if event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE):
pygame.quit()
sys.exit()

initialise display

pygame.init()
CLOCK = pygame.time.Clock()
DS = pygame.display.set_mode((900, 700))
pygame.display.set_caption("code.Pylet - Scrolling Background with Player")
FPS = 500

define some colors

BLACK = (0, 0, 0, 255)
WHITE = (255, 255, 255, 255)

bg = pygame.image.load("bg1.jpg").convert()

def fun():
pass

main loop

while True:
events()
help_menu = pygameMenu.Menu(DS, 200, 300, font='Arial', title='kak')

# help_menu = pygameMenu.TextMenu(surface, window...)
help_menu.add_option('Simple button', fun, align=pygameMenu.locals.ALIGN_LEFT)
#help_menu.add_option('Return to Menu', pygameMenu.events.MENU_BACK)

DS.blit(bg, (0, 0))



pygame.display.update()
CLOCK.tick(FPS)
DS.fill(BLACK)

Why is this happening?

Use DirtySprites and improve performances

To avoid CPU time consumption and have better performances on embedded devices (raspberry-pi), it could be good to avoid redraw the entire surface of the menu each time.

Pygame have basic classes to improve performances : DirtySprite and LayeredDirty which could be used in pygame-menu. See for instance: http://n0nick.github.io/blog/2012/06/03/quick-dirty-using-pygames-dirtysprite-layered

This does not imply to break everything, the current architecture can fit to this philosophy with minor changes: dirty flag in Widget class and redraw if dirty=True.

Add a scrollable menu

That would be interesting, some ideas i have:
render the entire menu as an image, then clip the menu from a certain "y" coordinate to "min(y+Hy. maxY)" (where Hy height of the menu, maxY maximum menu rendered height).

Using some kind of y-overflow slider then that "y" coordinate can be changed 🤔

Specify default option for selector

The selector object initially displays the first item in the list of items. It would be nice to be able to specify a default other than the first item in the list.

Remove config file

If only are used by Menu class I think this file is redundant, also no one user can edit this file if library is downloaded by pip.

self._menu._top is None

Having an issue with line 145 in menubar.py:
if not self._menu or not self._menu._top._prev:
It gives me an AttributeError: 'NoneType' object has no attribute '_prev'

However, if I change that line to:
if not self._menu:
it runs.

Is there a new parameter or something in version 2.2.0 that I am missing?

Other Programs

Is it possible to start other python programs from pygame-menu?

Remove window_width and window_height from Menu parameter

As compatibility with 2.2.0 is broken in #122... What if window_width and window_height parameters of Menu class are deleted?

Width and Height of the window can be retrieved using:

w, h = pygame.display.get_surface().get_size()

So it's pointless to require them as a parameter.

Support Chinese characters?

I tried to display Chinese characters, but they didn't display properly. Does it support Chinese characters, or does it mean configuring something? Thanks.

Merge TextMenu into Menu

Seeing the code, actually the add_text() method can be easily implemented in Menu class. So TextMenu seems useless.

.add_text() can be a simple instance of a new widget TextWidget that does not catch any input and cannot be selected. This solution englobes all the menus into a single and simple global Menu class.

Unable to transition screen more than once

I want to implement 3 menu screen transitions with the following code.

menu3 = MenuTemplate(surface=SURFACE, title="menu3")
menu3.add_option("back", pygameMenu.events.BACK)

menu2 = MenuTemplate(surface=SURFACE, title="menu2")
menu2.add_option("go to menu3", menu3)

menu1 = MenuTemplate(surface=SURFACE, title="menu1")
menu1.add_option("go to menu2", menu2)

clock = pygame.time.Clock()
while True:
    clock.tick(60)
    menu1.mainloop()

MenuTemplate is an inherited class of pygameMenu.Menu.

I expect following screen transitions:

menu1 -> menu2 -> menu3

In practice, however, only the transition from menu1 to menu2 works and cannot transition from menu2 to menu3.

Is this the intended behavior? Or is it a bug?

Limits on creating Menus

[EN]
I have this trouble on creating a big ammount of menus, the problem is when i get inside the "configurator menu", the screen looks like freezed but it stills working but badly, ill show the the code. Thanks.
[ES]
Tengo este problema que cuando creo una cierta cantidad de menus extras o como el código mostrado "menu configurador" muestra errores, al momento de abrir el menu de "configurador" todo funciona bien, pero al abrir otro menu como "Editar Skins" no funciona y se "Congela", no muestra las opciones dadas. Muchas gracias.

class GameMenu():
	def menu_del_juego(self):		

		#MENU JUGAR
		self.menu_jugar = pygameMenu.Menu(ventana,
										bgfun=background,
										color_selected=color_blanco,
										font=pygameMenu.fonts.FONT_BEBAS,
										font_color=color_negro,
										font_size=30,
										menu_alpha=0,
										menu_height=int(tamaño_del_menu[1]),
										menu_width=int(tamaño_del_menu[0]),
										onclose=PYGAME_MENU_DISABLE_CLOSE,
										option_shadow=False,
										title='Menu Principal',
										window_height=tamaño_del_menu[1],
										window_width=tamaño_del_menu[0]
										)

		self.menu_jugar.add_option('Empezar!', funcion_skin, SKIN)
		self.menu_jugar.add_selector('Escoger Skin', [('Default-Easy', 'DEFAULT-EASY'),
													 ('Goku-Easy', 'GOKU-EASY'),
													 ('Hulk-Easy', 'HULK-EASY'),

													 ('Default-Medium', 'DEFAULT-MEDIUM'),
													 ('Goku-Medium', 'GOKU-MEDIUM'),
													 ('Hulk-Medium', 'HULK-MEDIUM'),

													 ('Default-Hard', 'DEFAULT-HARD'),
													 ('Goku-Hard', 'GOKU-HARD'),
													 ('Hulk-Hard', 'HULK-HARD'),],
								onreturn = False,
								onchange = cambiar_skin)
		self.menu_jugar.add_option('REGRESAR AL MENU PRINCIPAL', PYGAME_MENU_BACK)

		

		# MENU SOBRE NOSOTROS
		self.menu_sobre_nosotros = pygameMenu.TextMenu(ventana,
												bgfun=background,
												color_selected=color_negro,
												font=pygameMenu.fonts.FONT_BEBAS,
												font_color=color_negro,
												font_size=30,
												menu_alpha=0,
												menu_height=int(tamaño_del_menu[1]),
												menu_width=int(tamaño_del_menu[0]),
												onclose=PYGAME_MENU_DISABLE_CLOSE,
												option_shadow=False,
												title='SOBRE NOSOTROS',
												window_height=tamaño_del_menu[1],
												window_width=tamaño_del_menu[0]
												)
		self.menu_sobre_nosotros.add_option("REGRESAR AL MENU PRINCIPAL", PYGAME_MENU_BACK)
		for self.m in SOBRE_NOSOTROS:
			self.menu_sobre_nosotros.add_line(self.m)
		self.menu_sobre_nosotros.add_line(PYGAMEMENU_TEXT_NEWLINE)




		# MENU COMO JUGAR
		self.menu_como_jugar = pygameMenu.TextMenu(ventana,
											bgfun=background,
											color_selected=color_blanco,
											font=pygameMenu.fonts.FONT_BEBAS,
											font_color=color_negro,
											font_size=30,
											menu_alpha=0,
											menu_height=int(tamaño_del_menu[1] ),
											menu_width=int(tamaño_del_menu[0]),
											onclose=PYGAME_MENU_DISABLE_CLOSE,
											option_shadow=False,
											title='COMO JUGAR',
											window_height=tamaño_del_menu[1],
											window_width=tamaño_del_menu[0]
											)
		self.menu_como_jugar.add_option("REGRESAR AL MENU PRINCIPAL", PYGAME_MENU_BACK)
		for self.m in COMO_JUGAR:
			self.menu_como_jugar.add_line(self.m)
		self.menu_como_jugar.add_line(PYGAMEMENU_TEXT_NEWLINE)

		# Opciones del Menú Configurador
		# Opción 1: Seleccionar Skins
		# Opción 2: Elegir fondo del juego
		# Opción 3: Cambiar la dificultad
		# Opción 4: Configurar obstáculos y powerups

		# MENÚ EDICIÓN SKINS
		self.menu_eskins = pygameMenu.Menu(ventana,
										bgfun=background,
										color_selected=color_blanco,
										font=pygameMenu.fonts.FONT_BEBAS,
										font_color=color_negro,
										font_size=30,
										menu_alpha=0,
										menu_height=int(tamaño_del_menu[1]),
										menu_width=int(tamaño_del_menu[0]),
										onclose=PYGAME_MENU_DISABLE_CLOSE,
										option_shadow=False,
										title='Editar Skins',
										window_height=tamaño_del_menu[1],
										window_width=tamaño_del_menu[0]
										)
		self.menu_eskins.add_option('REGRESAR AL MENU PRINCIPAL', PYGAME_MENU_BACK)
		self.menu_eskins.add_option('REGRESAR AL MENU PRINCIPALdas', PYGAME_MENU_BACK)


		# MENÚ SELECCIÓN FONDO
		self.menu_efondo = pygameMenu.Menu(ventana,
										bgfun=background,
										color_selected=color_blanco,
										font=pygameMenu.fonts.FONT_BEBAS,
										font_color=color_negro,
										font_size=30,
										menu_alpha=0,
										menu_height=int(tamaño_del_menu[1]),
										menu_width=int(tamaño_del_menu[0]),
										onclose=PYGAME_MENU_DISABLE_CLOSE,
										option_shadow=False,
										title='Seleccionar Fondo',
										window_height=tamaño_del_menu[1],
										window_width=tamaño_del_menu[0]
										)
		self.menu_efondo.add_option('Empezar!', game.ChasquiRunner)
		self.menu_efondo.add_option('REGRESAR AL MENU PRINCIPAL', PYGAME_MENU_BACK)

		# MENÚ CONFIGURACIÓN DE DIFICULTAD
		self.menu_edifi = pygameMenu.Menu(ventana,
										bgfun=background,
										color_selected=color_blanco,
										font=pygameMenu.fonts.FONT_BEBAS,
										font_color=color_negro,
										font_size=30,
										menu_alpha=0,
										menu_height=int(tamaño_del_menu[1]),
										menu_width=int(tamaño_del_menu[0]),
										onclose=PYGAME_MENU_DISABLE_CLOSE,
										option_shadow=False,
										title='Cambiar dificultad',
										window_height=tamaño_del_menu[1],
										window_width=tamaño_del_menu[0]
										)
		self.menu_edifi.add_option('Empezar!', game.ChasquiRunner)
		self.menu_edifi.add_option('REGRESAR AL MENU PRINCIPAL', PYGAME_MENU_BACK)

		# MENÚ CONFIGURACIÓN DE OBSTÁCULOS Y POWERUPS
		self.menu_obspw = pygameMenu.Menu(ventana,
										bgfun=background,
										color_selected=color_blanco,
										font=pygameMenu.fonts.FONT_BEBAS,
										font_color=color_negro,
										font_size=30,
										menu_alpha=0,
										menu_height=int(tamaño_del_menu[1]),
										menu_width=int(tamaño_del_menu[0]),
										onclose=PYGAME_MENU_DISABLE_CLOSE,
										option_shadow=False,
										title='Configurar obstaculos y powerups',
										window_height=tamaño_del_menu[1],
										window_width=tamaño_del_menu[0]
										)
		self.menu_obspw.add_option('Empezar!', game.ChasquiRunner)
		self.menu_obspw.add_option('REGRESAR AL MENU PRINCIPAL', PYGAME_MENU_BACK)


		# MENU CONFIGURADOR
		self.menu_configurador = pygameMenu.TextMenu(ventana,
										bgfun=background,
										color_selected=color_blanco,
										font=pygameMenu.fonts.FONT_BEBAS,
										font_color=color_negro,
										font_size=30,
										menu_alpha=0,
										menu_height=int(tamaño_del_menu[1]),
										menu_width=int(tamaño_del_menu[0]),
										onclose=PYGAME_MENU_DISABLE_CLOSE,
										option_shadow=False,
										title='Menu Configurador',
										window_height=tamaño_del_menu[1],
										window_width=tamaño_del_menu[0]
										)

		self.menu_configurador.add_option('Editar skins', self.menu_eskins)
		self.menu_configurador.add_option('Editar fondo', self.menu_efondo)
		self.menu_configurador.add_option('Cambiar dificultad', self.menu_edifi)
		self.menu_configurador.add_option('Configurar obstaculos y powerups', self.menu_obspw)
		self.menu_configurador.add_option('Regresar al menu principal', PYGAME_MENU_BACK)

		# MENU PRINCIPAL
		self.menu_principal = pygameMenu.TextMenu(ventana,
										bgfun=background,
										color_selected=color_blanco,
										font=pygameMenu.fonts.FONT_BEBAS,
										font_color=color_negro,
										font_size=30,
										menu_alpha=0,
										menu_height=int(tamaño_del_menu[1]),
										menu_width=int(tamaño_del_menu[0]),
										onclose=PYGAME_MENU_DISABLE_CLOSE,
										option_shadow=False,
										title='Menu Principal',
										window_height=tamaño_del_menu[1],
										window_width=tamaño_del_menu[0]
										)

		self.menu_principal.add_option('Empezar Juego', self.menu_jugar)
		self.menu_principal.add_option('Sobre Nosotros', self.menu_sobre_nosotros)
		self.menu_principal.add_option('Como jugar', self.menu_como_jugar)
		self.menu_principal.add_option('Configuracion de Objetos', self.menu_configurador)
		self.menu_principal.add_option('Salir', PYGAME_MENU_EXIT)

		# Loop del menu
		while True:
			# FPS DEL JUEGO
			clock.tick(60)
			# Eventos del menu
			eventos = pygame.event.get()
			for evento in eventos:
				if evento.type == QUIT:
					pygame.quit()
					sys.exit()

			# MENU PRINCIPAL
			self.menu_principal.mainloop(eventos)
			self.menu_configurador.mainloop(eventos)

			# Flip
			pygame.display.flip()

Long scroll menus

This seems like a pretty obvious addition: long scrolling menus, for when there's more items than will fit.

Any idea off the top of your head what would be involved?

Cannot run example and example2

When I trie to run the examples is show me an error that cannot import the module Menu, especific in the line 19 from the init.py file

Improve mouse handling

Typical OSes handle mouse selection as follows:

  • on mouse down, the widget is highlighted
  • on mouse up, the widget function is executed, but only if it is the same widget as the mouse down happened in.

pygame-menu departs from this in two ways:

  • there is no visual indication of mouse down
  • on mouse up, the widget function is executed, even if the initial mousedown happened in a different widget.

The following change to the mouse event handling code makes the functioning a bit closer to standard:

                elif self._mouse and event.type == _pygame.MOUSEBUTTONDOWN:
                    for index in range(len(self._actual._option)):
                        widget = self._actual._option[index]
                        if widget.get_rect().collidepoint(*event.pos):
                            self._select(index)

                elif self._mouse and event.type == _pygame.MOUSEBUTTONUP:
                    widget = self._actual._option[self._actual._index]
                    if widget.get_rect().collidepoint(*event.pos):
                        widget.update(events)  # This option can change the current menu to a submenu
                        break_mainloop = True  # It is updated
                        break

License question

I know this is under the GPL license. Does this mean any code that uses this must use the GPL license and be open source? If so, is there any way around that? Thanks.

OnReturn doesn't work with joystick input

I am making a menu that can work with a controller, and navigating the menus works fine, but when i make selection switches that use onreturn instead of onchange, nothing happens. they work when i hit enter on the keyboard, but not the A button on my controller.

Utility file for common methods

Is there a file designated for methods that are common among multiple files? For instance, if there is a method that is exactly the same method in both menu.py and widget.py, and we wanted to refactor it into a different, common "utilities" file, does that file exist? I'm happy to make one if it doesn't already exist.

Joystick initialization issue

pygame docs say that pygame.joystick.init() is automatically called by pygame.init(). This means that in the Menu constructor, pygame.joystick.get_init() can return true and hence no joysticks get supported. I suggest changing the relevant code to:

        self._joystick = joystick_enabled
        if self._joystick:
            if not _pygame.joystick.get_init():
                _pygame.joystick.init()
            for i in range(_pygame.joystick.get_count()):
                _pygame.joystick.Joystick(i).init()

Use same key to close menu and sub-menu (use ESC instead of BACK)

Hello,

Is it possible to use the same key (e.g. ESC) to close the main menu (Menu()) and a submenu (TextMenu())?

I tried to set the variable MENU_CTRL_BACK:

config_controls.MENU_CTRL_BACK = pygame.locals.K_ESCAPE

But after that, it is no more possible to close the main menu.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.