我想通过更改屏幕的通用功能来减少我的代码。我的屏幕名称为数字,例如名称:“2”..当您单击底部表格中的某个列表时,我想更改某个屏幕。
在.py
def show_bottom_sheet(self):
bs = MDListBottomSheet()
bs.add_item("Models", lambda x: x,icon='account-group-outline')
for y in 1,2,3,4,12,13,14,21,23,24,31,32,34,41,42,43,123,124,134,234:
bs.add_item(f"example {y} ", lambda x= y: self.behavior(x), icon='account-group-outline')
bs.open()
def behavior(self, x):
self.manager.current = str(x)
在我改变之前是这样的,但是对于每一个数字,它太长了
def behavior2(self):
self.manager.current = "2"
我该如何解决?