Python pygtk的Unicode问题
我有以下问题: 我正在用pygame、pygtk和pgu为python中的XO(OLPC机器)编写一个问答游戏。 当用户(一个孩子)写东西时,文本区域(来自pgu)不会使用特殊字符,如ñ、ó、á等。 我已经尝试了一个较小的程序,只与pygame和pgu,它工作得很好。我认为问题可能在于pygtk中的unicode,但我不知道如何检查或纠正它Python pygtk的Unicode问题,python,unicode,pygtk,pygame,Python,Unicode,Pygtk,Pygame,我有以下问题: 我正在用pygame、pygtk和pgu为python中的XO(OLPC机器)编写一个问答游戏。 当用户(一个孩子)写东西时,文本区域(来自pgu)不会使用特殊字符,如ñ、ó、á等。 我已经尝试了一个较小的程序,只与pygame和pgu,它工作得很好。我认为问题可能在于pygtk中的unicode,但我不知道如何检查或纠正它 app = gui.App()#gui is from pgu c = gui.Container(width =1200,height =
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()
当我按下ñ键时,我进入日志文件:key ntilde unrecognized
请帮帮我,我被卡住了,我必须交付软件 导入gtk时,默认编码将设置为utf-8
import gtk, sys
print sys.getdefaultencoding()
由于它在没有gtk的情况下运行良好,我想它可能与编码有关