2017-07-19 24 views
-1

如何動態填充標籤和TextInput?提取應該會自動填入標籤和TextInput。如何在kivy(python)中使用map(key,value)?

 BoxLayout: 
      padding: 50, 50, 50, 50 
      orientation: 'horizontal' 

      BoxLayout: 
       spacing: 50 
       orientation: 'vertical' 
       size_hint_x: 1 
       Label: 
        text: 'a' 
       Label: 
        text: 'b' 
       Label: 
        text: 'c' 

      BoxLayout: 
       spacing: 50 
       orientation: 'vertical' 
       TextInput: 
        text: 'Goc' 
       TextInput: 
        text: 'Coc' 
       TextInput: 
        text: 'Dow' 
+0

? – Tshirtman

+0

是的,親愛的@Tshirtman,但是如何在標籤和TextInput中獲取數據?可能是一些循環和小功能應該在那裏。順便說一句,我試過RecycleView,它不是爲我而來的。 – crazyDelight

回答

1

你應該給一個id:對每個插件 (如:

TextInput: 
    id: ti1 
TextInput: 
    id: ti2 

等你關心的所有部件)

(見Kivy官方網站),並填寫他們無論你想要訪問小部件的「文本」屬性,就像這樣: self.ids.ti1.text ='jkhgk ....' 其中self是你的部件:

class Test(SomeClass): 
    def settext(self): 
     self.ids.ti1.text='Cog' or whatever... 

和你看看RecycleView結合以任何方式此的setText FUNC(KV中的文件或文件PY)添加到您控制的on_press,on_check等

相關問題