字母键(A-Z( 数字键(0-9(在使用wx的文本编辑器中映射到Unicode值。文本控制。
下面给出了遇到错误的行,
self.statusbar.SetStatusText(engine.roman2mal(self.word.decode('utf-8')),0)
错误消息如下所示,
Traceback (most recent call last):
File "F:EZHUTHANI_WINezhuthanibeditor.py", line 498, in PreviewConv
self.statusbar.SetStatusText(engine.roman2mal(self.word.decode('utf-8')),0)
File "C:Python27libencodingsutf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5: ordinal not in range(128)
有没有办法映射这些键(回车键、空格键、退格键(? 其他键映射如下,
keymap = {}
keymap['a'] = u'u0D05';
keymap['A'] = u'u0D06';
self.statusbar.SetStatusText(engine.roman2mal(self.word.decode('utf-8')),0)
您必须删除.decode函数,然后代码将如下所示
self.statusbar.SetStatusText(engine.roman2mal(self.word),0)
我不完全确定您要实现什么目标,但听起来您想使用
wx.WXK_BACK
wx.WXK_ESCAPE
wx.WXK_RETURN
...
也许
keymap = {}
keymap[wx.WXK_ESCAPE] = u'<ESCAPE>'
...