level 6
wwacdroot
楼主
使用wxpython做界面,做一个下拉框,一开始用的是combobox,readonly,在win下好用,随便一个地方一点就是下拉,但换了平台就不好用了,一定要点最左边的箭头才会下拉。查了一下,可以用wxChoice。功能是实现了,但如何获取内容成了问题。
clyChoices = ['aa','bb','cc','dd']
self.cly = wx.Choice( panel, wx.ID_ANY, wx.DefaultPosition, wx.Size( 200,-1 ), clyChoices, 0 )
self.cly.SetSelection( 0 )
下拉有四个值,默认显示第1个。
print(self.cly.GetValue())==='Choice' object has no attribute 'GetValue'==没有getvalue的写法
print(self.cly.GetString())===Chilce.GetString():not enough arguments==有getstring,但写法不对
现在只能是:
self.cly.GetItems()====获得列表: ['aa','bb','cc','dd']
self.cly.GetSelection()===获得第几项
合并成:print ( self.cly.GetItems() [ self.cly.GetSelection() ])
这样写可以得到内容,但写法太复杂了,
正确的
写法应该是怎么样的?
2021年12月04日 12点12分
1
clyChoices = ['aa','bb','cc','dd']
self.cly = wx.Choice( panel, wx.ID_ANY, wx.DefaultPosition, wx.Size( 200,-1 ), clyChoices, 0 )
self.cly.SetSelection( 0 )
下拉有四个值,默认显示第1个。
print(self.cly.GetValue())==='Choice' object has no attribute 'GetValue'==没有getvalue的写法
print(self.cly.GetString())===Chilce.GetString():not enough arguments==有getstring,但写法不对
现在只能是:
self.cly.GetItems()====获得列表: ['aa','bb','cc','dd']
self.cly.GetSelection()===获得第几项
合并成:print ( self.cly.GetItems() [ self.cly.GetSelection() ])
这样写可以得到内容,但写法太复杂了,
正确的
写法应该是怎么样的?