我正在尝试获取文本输入,将其保存到jsonstore,然后使用jsonstore中的每个键作为按钮上的文本。我已经阅读了我能想到的所有相关文档,我尝试过搜索google,我也尝试过在这里搜索。我试过索引键,但不支持。我真的搞不懂。这是最后一个主要功能,我需要让一切运行。你知道吗
这是我的python脚本。你知道吗
class ScreenSix(Screen):
def Create_ShopList(self):
store = JsonStore('user_meals.json')
ingredients = store.get(self._name.text)['ingredients']
return ingredients
def Meal_Options(self):
store = JsonStore('users_meals.json')
meals = store.keys()
return meals
这是我kv文件的相关部分。你知道吗
<ScreenSix>:
name: 'shoplist'
id: shoplist
FloatLayout:
canvas:
Rectangle:
pos: self.pos
size: self.size
source: '20.png'
Label:
text: 'Create Shopping List'
font_size: 60
pos_hint: {'center_x':.5,'center_y':.8}
color: 0,0,0,1
Label:
text: 'Which meals would you like to add?'
font_size: 40
pos_hint: {'center_x':.5,'center_y':.7}
color: 0,0,0,1
Button:
text: 'Menu'
font_size: 36
size_hint: .2,.1
pos_hint: {'left':1,'y':0}
on_release: app.root.current='menu'
Button:
text: 'Quit'
font_size: 36
size_hint: .2,.1
pos_hint: {'right':1,'y':0}
on_release: app.root.current='open'
Button:
text: ''
font_size: 36
size_hint: .2,.1
pos_hint: {'center_x':.18,'center_y':.6}
on_release: root.Create_ShopList()
Button:
text: ''
font_size: 36
size_hint: .2,.1
pos_hint: {'center_x':.39,'center_y':.6}
Button:
text: ''
font_size: 36
size_hint: .2,.1
pos_hint: {'center_x':.6,'center_y':.6}
Button:
text: ''
font_size: 36
size_hint: .2,.1
pos_hint: {'center_x':.81,'center_y':.6}
我想让按钮文本成为保存为json存储中的键的名称。最后几个按钮是我想让餐名显示在上面的按钮,我正在使用第一个按钮作为测试按钮,同时我正在尝试找出它。我担心我可能做不到,如果是这样的话,我不知道有什么好的选择。你知道吗
你可以用
RecycleView
来做这个。我对此做了一个小小的解释。
试试这个:
相关问题 更多 >
编程相关推荐