【发布时间】:2012-07-13 00:57:24
【问题描述】:
这是我的代码
python 2.7 & wxpython 2.8
这3个textctrl,在chat_c(textctrl)
我想让 chat_c 和 text_c 像一个聊天室
输入是chat_c 输出是text_c
这就是我使用的原因
def OnReturnDown(self,e):
key = e.GetKeyCode()
self.text_c.SetValue(key) #for check out but doesn't work
if key == wx.WXK_RETURN:
self.text_c.SetValue(self.chat_c.GetValue())
#key bind
self.chat_c.Bind(wx.EVT_KEY_DOWN, self.OnReturnDown)
这是错误信息
Traceback (most recent call last):
File "C:\workspace\wx_python_test\main_chat_client.py", line 239, in OnReturnDown
self.text_c.SetValue(key) #for check out but doesn't work
File "C:\Python27\Lib\site-packages\wx-2.8-msw-unicode\wx\_controls.py", line 1754, in SetValue
return _controls_.TextCtrl_SetValue(*args, **kwargs)
TypeError: String or Unicode type required
那是什么?需要Unicode类型???
也许改变 textctrl 的样式?
如何解决这个问题?
【问题讨论】:
标签: event-handling wxpython keycode textctrl