我有以下问题:我正在使用pygame,pygtk和pgu在python中为XO (OLPC机器)编写一个问题/答案游戏。当用户(一个孩子)写东西时,textarea (来自pgu)不接受特殊字符,如ñ、ó、á等。我尝试了一个较小的程序,只使用pygame和pgu,它工作得很好。我认为问题可能出在pygtk中的unicode,但我不知道如何检查或纠正它。
app = gui.App()#gui is from pgu
c = gui.Container(width =1200,height = 900)
background = pygame.display.get_surface()
app.init(c,background)
#load initial screen
while self.running and salir==1:
background.blit(self.pantalla,(0,0))
x,y = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.running = False
return
if event.type == pygame.KEYDOWN:
if event.unicode.isalnum():
print event.unicode
print "Evento pygame:",event.key
if event.key == pygame.K_DOWN:
exit()
app.event(event)
app.paint(background)
app.update(background)
pygame.display.flip()
#now I have to manage pygtk events:
p = gtk.events_pending()
while p:
gtk.main_iteration()当我按N键时,我会进入日志文件: key ntilde unrecognized。
请帮帮忙,我卡住了,我必须把软件送过去。
发布于 2010-12-30 14:05:58
导入gtk时,默认编码将设置为utf-8。
import gtk, sys
print sys.getdefaultencoding()由于它在没有gtk的情况下工作得很好,我猜这可能与编码有关。
https://stackoverflow.com/questions/4475682
复制相似问题