需要字符串或 Unicode 类型,wxPython StaticText
我正在尝试制作一个 wxPython 静态文本小部件。由于某种原因,我不断收到以下错误。
片段:
self.Label = wx.StaticText(self, pos=(sw/2.0 - w/2.0, sh/2.0 - h/2.0), label='hello')
错误:
", line 238, in make_label
self.Label = wx.StaticText(self, pos=(sw/2.0 - w/2.0, sh/2.0 - h/2.0), label='hello')
File "C:\Python26\lib\site-packages\wx-2.8-msw-ansi\wx\_core.py", line 8500, in SetLabel
return _core_.Window_SetLabel(*args, **kwargs)
TypeError: String or Unicode type required
I'm trying to make a wxPython static text widget. For some reason I keep getting the error below.
Snippet:
self.Label = wx.StaticText(self, pos=(sw/2.0 - w/2.0, sh/2.0 - h/2.0), label='hello')
Error:
", line 238, in make_label
self.Label = wx.StaticText(self, pos=(sw/2.0 - w/2.0, sh/2.0 - h/2.0), label='hello')
File "C:\Python26\lib\site-packages\wx-2.8-msw-ansi\wx\_core.py", line 8500, in SetLabel
return _core_.Window_SetLabel(*args, **kwargs)
TypeError: String or Unicode type required
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Label 是 wx.Frame 的一个属性,不允许尝试向它分配除 String 之外的任何内容。
供参考: http://www.wxpython.org/docs/ api/wx.Window-class.html#SetLabel(wx.Frame是wx.Window的子类)
Label is a property of wx.Frame, and trying to assign anything other than a String to it is not allowed.
For reference: http://www.wxpython.org/docs/api/wx.Window-class.html#SetLabel (wx.Frame is a subclass of wx.Window)
您需要指定所有参数名称,self 被视为某种数据类型而不是参数,因此在代码中您必须将
self
替换为parent = self
You need to specify all the argument names , self is being taken as datatype of some sort not as an argument, So in your code your have to replace
self
withparent = self