This commit is contained in:
yumoqing 2021-04-02 17:57:59 +08:00
parent c40ce7528f
commit ef7de84671

View File

@ -191,6 +191,7 @@ class MyDropDown(DropDown):
return '' return ''
def setData(self,data): def setData(self,data):
Logger.info('TextInput: setData data=%s', data)
self.si_data = data self.si_data = data
self.clear_widgets() self.clear_widgets()
h = self.options.get('height',2.5) h = self.options.get('height',2.5)
@ -199,8 +200,10 @@ class MyDropDown(DropDown):
a['height'] = CSize(h) a['height'] = CSize(h)
a['font_size'] = CSize(self.options.get('font_size',1)) a['font_size'] = CSize(self.options.get('font_size',1))
for d in data: for d in data:
dd = (d[self.valueField],d[self.textField]) v = d.get(self.valueField, None)
b = Button(text=d[self.textField],**a) t = d.get(self.textField, None)
dd = (v,t or v)
b = Button(text=dd[1],**a)
setattr(b,'kw_data',dd) setattr(b,'kw_data',dd)
b.bind(on_release=lambda btn: self.select(btn.kw_data)) b.bind(on_release=lambda btn: self.select(btn.kw_data))
self.add_widget(b) self.add_widget(b)