WxPython 组合框字符串未正确返回
WxPython Combobox string not returning correctly
每当我在 WxPython 中尝试 return 来自 ComboBox 的字符串时,它 return 字符串不正确,它 return 是这样的:
<bound method CommandEvent.GetString of <wx._core.CommandEvent; proxy of <Swig Object of type 'wxCommandEvent *' at 0x27e818> >>
并且我希望将它 return 字符串输入到组合框中:
self.firmwarelist = wx.ComboBox(panel, pos=(170,22), choices=["6.61","6.61 N1000/Go","6.60","6.60 N1000/Go","6.35","6.35 N1000/Go","6.39","6.39 N1000/Go","6.20","6.10","6.10 N1000/Go","6.60","5.50","5.03","5.00","4.05","4.01","4.00","3.52","3.50","1.50"]
)
self.Bind(wx.EVT_COMBOBOX, self.e, self.firmwarelist)
这是 ComboBox return 到
的位置
def e(self,e):
global p
i = e.GetString
p = str(i)
print p
return p
一定是
i = e.GetString()
否则不是函数调用
编辑:顺便说一句,将函数命名为与参数相同是一个非常糟糕的主意。尝试将其中一个 e 更改为其他内容,例如 f.
def e(self, f):
每当我在 WxPython 中尝试 return 来自 ComboBox 的字符串时,它 return 字符串不正确,它 return 是这样的:
<bound method CommandEvent.GetString of <wx._core.CommandEvent; proxy of <Swig Object of type 'wxCommandEvent *' at 0x27e818> >>
并且我希望将它 return 字符串输入到组合框中:
self.firmwarelist = wx.ComboBox(panel, pos=(170,22), choices=["6.61","6.61 N1000/Go","6.60","6.60 N1000/Go","6.35","6.35 N1000/Go","6.39","6.39 N1000/Go","6.20","6.10","6.10 N1000/Go","6.60","5.50","5.03","5.00","4.05","4.01","4.00","3.52","3.50","1.50"]
)
self.Bind(wx.EVT_COMBOBOX, self.e, self.firmwarelist)
这是 ComboBox return 到
的位置def e(self,e):
global p
i = e.GetString
p = str(i)
print p
return p
一定是
i = e.GetString()
否则不是函数调用
编辑:顺便说一句,将函数命名为与参数相同是一个非常糟糕的主意。尝试将其中一个 e 更改为其他内容,例如 f.
def e(self, f):