I've just started out coding in python, and I was playing around with text boxes, when I got an error (AttributeError: 'Event' object has no attribute 'unicode'). From what I've found on a few forums, this error is because I use Python 3, but I couldn't find anywhere an alternative I could use.
for event in pygame.event.get():
# quit
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
if input_rect.collidepoint(event.pos):
active = True
else:
active = False
if event.type == pygame.KEYDOWN:
# Check for backspace
if event.key == pygame.K_BACKSPACE:
user_text = user_text[:-1]
else:
user_text += event.unicode # here is where I recieve the error
The exact error is:
user_text += event.unicode
^^^^^^^^^^^^^
AttributeError: 'Event' object has no attribute 'unicode'
I've tried using str, and some other solutions but I didn't manage to implement them.
source https://stackoverflow.com/questions/74928810/what-alternative-can-i-use-for-event-unicode
Comments
Post a Comment