1

Though a button calling pygame_menu.events.EXIT works to close the whole Pygame program, one calling pygame_menu.events.CLOSE does not seem to do anything. (Edit: I also tried the menu close() method, but with the same result.) I would like it to close the menu, allowing the program to proceed using the input recorded by the menu.

Here is my minimum reproducible example:

import pygame
import pygame_menu

pygame.init()

screen = pygame.display.set_mode((1000, 700))

menu = pygame_menu.Menu(
    'Hey',
    1000,
    700
)

menu.add.button(
    'Close',
    pygame_menu.events.CLOSE
)
menu.mainloop(screen)

The menu opens and the button appears, but clicking the button does nothing. What should I be doing differently?

Many thanks!

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
Lyndon Gingerich
  • 604
  • 7
  • 17
  • I think You don't close anything but rather hide or more like do not show it anymore for example if you `.blit` something from menu stop doing that when moving on – Matiiss Mar 31 '21 at 22:20
  • ok so I relooked and I don't see any function that would collect the data, for example add a function to the button that will actually do something – Matiiss Mar 31 '21 at 22:22
  • @Matiiss I have selectors with `onchange` collecting data. I'll see whether I can rewrite it. What use is `events.CLOSE`, then? – Lyndon Gingerich Mar 31 '21 at 22:37
  • 1
    honestly I have no idea. it seems to close events – Matiiss Mar 31 '21 at 22:38
  • @Matiiss That's a valid answer to my question, by the way. – Lyndon Gingerich Mar 31 '21 at 22:38
  • what do You mean by valid and here are some sources about event in pygame: https://www.pygame.org/docs/ref/event.html – Matiiss Mar 31 '21 at 22:39
  • I mean that you could post your first two comments as an answer. Interesting. Is there a link between Pygame events and pygame_menu events? – Lyndon Gingerich Mar 31 '21 at 22:41
  • oh, that is a bit strange. I know nothing about pygame_menu You should read their docs – Matiiss Mar 31 '21 at 22:42

0 Answers0