Exemplo n.º 1
0
def sendlabeltoboard(string,board):
	inputlabel=myfont.render(string,1,(255,0,100))
	board.delinput()
	textpos=inputlabel.get_rect()
	textpos.center = ((800-inputlabel.get_rect().width)/2,(600-inputlabel.get_rect().height)/2)
	board.addinput(inputlabel,textpos.center)
	board.render()
	pygame.display.update()
Exemplo n.º 2
0
			pygame.display.update()

	for event in pygame.event.get():
		if event.type == QUIT:
			pygame.quit()
			sys.exit()

		if event.type == pygame.KEYDOWN:
			#pressed letter?
			if stringbuf and event.key != pygame.K_RETURN:
				if event.key==K_BACKSPACE:
					inputstring=inputstring[:-1]
				elif event.key==pygame.K_ESCAPE:
					inputstring=""
					board.delinput()
					board.render()
					pygame.display.update()
					stringbuf=False
					continue				
				else:
					try:
						#get pressed letter
						inputstring+=chr(event.key)
					except:
						print "oops"
				#show label on board
				sendlabeltoboard(inputstring,board)

			else:
				if event.key == pygame.K_ESCAPE:
					pygame.quit()