I have just started with pygame and I wanna make two working input boxes, were you can write, delete, send (with the send key) and edit (just by re-clicking the input box).
P.S. Please don’t make very complicate code introducing many methods and more… just be simple please. 🙂
Do you know how to export the python file into an android/ios/windows app without glitching the content?
This is the python code that I’ve made:
`class inputBox1:
input = pygame.surface.Surface((160, 20))
inputPos = input.get_rect()
input.fill(black)
inputPos.centerx = loveTestPageText.textPos.centerx
inputPos.centery = loveTestPageText.textPos.centery + 26
active = False
background.blit(input, inputPos)
class textInputBox1:
font = pygame.font.Font(None, 26)
text = font.render(“Nome del primo”, 1, white)
textPos = text.get_rect()
textPos.centerx = inputBox1.inputPos.centerx
textPos.centery = inputBox1.inputPos.centery
background.blit(text, textPos)
class inputBox2:
input = pygame.surface.Surface((160, 20))
inputPos = input.get_rect()
input.fill(black)
inputPos.centerx = inputBox1.inputPos.centerx
inputPos.centery = inputBox1.inputPos.centery + 26
active = False
background.blit(input, inputPos)
class textInputBox2:
font = pygame.font.Font(None, 26)
text = font.render(“Nome del secondo”, 1, white)
textPos = text.get_rect()
textPos.centerx = inputBox2.inputPos.centerx
textPos.centery = inputBox2.inputPos.centery
background.blit(text, textPos)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
if event.type == pygame.MOUSEBUTTONDOWN:
pos = pygame.mouse.get_pos()
if inputBox1.inputPos.collidepoint(pos):
print("Clicked on 1st Input Box")
inputBox1.active = True
textInputBox1.text = textInputBox1.font.render(" ", 1, white)
if inputBox2.inputPos.collidepoint(pos):
print("Clicked on 2nd Input Box")
inputBox2.active = True
textInputBox2.text = textInputBox2.font.render(" ", 1, white)
#if event.type == pygame.KEYDOWN and inputBox1.active == True:
# how can i can write into the box?
# same for the 2nd box`
And this is how it appears:
https://i.sstatic.net/oTjyce1A.png
P.S. Please don’t make very complicate code introducing many methods and more… just be simple please. 🙂
Marco is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.