我正在尝试使用Kivy和KivyMD创建一个SmartTiles网格,如何绑定和创建每个tile的动态弹出窗口
我正在运行Kivy和KivyMD,我尝试使用一个函数创建弹出窗口,但是当我将它们绑定到磁贴时,它将只显示在所有磁贴上创建的最后一个弹出窗口(itemsBase只返回2个字符串列表)
def set_items(self):
titleB, infoB = itemsBase()
for y in range(1,8):
pop = self.callbackPopItemBase(str(titleB[y-1]), str(infoB[y-1]))
self.main_widget.ids.item_base.add_widget(
SmartTile(source='images/items/%d.png' % y, on_release=lambda x: pop.open()))
def callbackPopItemBase(self, title, info):
pop = Popup(
size_hint = (None, None), size=(dp(200), dp(300)))
box = BoxLayout(spacing=dp(10), orientation='vertical')
l1 = LabelPop(text=title, font_style='H6')
l2 = LabelPop(text=info)
box.add_widget(l1)
box.add_widget(l2)
pop.add_widget(box)
return pop
我想能够有不同的弹出每个瓷砖,而不必手动创建每个
目前没有回答
相关问题 更多 >
编程相关推荐