Where it says user_input = menu.add.text_input('User: ') or age_input = menu.add.text_input('Age: '), you can write something. I need to assign the words that are written to a variable. How could I do it?
import pygame
import pygame_menu
import random
pygame.init()
#Size - name of the window
surface = pygame.display.set_mode((600, 400))
pygame.display.set_caption("Example")
def game():
#Variables
score = 0
user_age = age_input.get_value()
user_name = user_input.get_value()
while True:
x = random.randint(0, 10)
y = random.randint(0, 10)
z = x + y
print(str(x) + "+" + str(y))
result = int(input())
if result == z:
print("Correct")
score = score + 5
else:
if result != z:
stop = input("Wrong! Wanna stop? ")
if stop == ("yes"):
print("You have " + str(score) + " points")
break
else:
continue
menu = pygame_menu.Menu('Menu', 600, 400,
theme=pygame_menu.themes.THEME_BLUE)
user_input = menu.add.text_input('User: ')
age_input = menu.add.text_input('Age: ')
menu.add.button('Start', game)
menu.add.button('Exit', pygame_menu.events.EXIT)
print (user_input)
print (age_input)
menu.mainloop(surface)
age = menu.add.text_input('Age: ', font_name = font1,font_color = 'Black'). Got that from hereprint(age)it will be at least None (or an empty string which is kinda the same you just won't really see that anything has been printed) but if it has some value it will print that valuemenu.mainloop(surface)?<pygame_menu.widgets.widget.textinput.TextInput object at 0x000001C5F7B8CD00>. I don't know what that means. Anyway, is there any other way?