python - Kivy, how to use datas in canvas -


i've list of products , wanna display labels. know how fetch datas textinput wanna display list in canvas.

how can ?

edit:

i have datas in 'global':

products = [{'name' : 'coca' , 'price' : 1.8000},{'name' : 'fanta' , 'price' : 1.8000}] 

and want display in gridlayout 2 cols, x rows, 2 labels, 1 name , other price of fanta, coca , others ...

<commandescreen>:     gridlayout:         rows: 4         cols: 2         button:             text: 'coca'         label:             text: '1.80 euros'         button:             text: 'orangina'         label:             text: '1.80 euros'         button:             text: 'ajouter'         button:             text: 'quitter'             on_press: root.manager.current = 'menu' 

a way go add in python code in class definition:

from kivy.uix.label import label  class commandescreen(screen):     def __init__(self, **kwargs):         super(commandescreen, self).__init__(**kwargs)         products = [{'name' : 'coca' , 'price' : 1.8000},{'name' : 'fanta' , 'price' : 1.8000}]         p in products:             self.gl.add_widget(label(text=p['name']))             self.gl.add_widget(label(text=str(p['price'])) 

in kv, that:

<commandescreen>:     gl: gl     gridlayout:         rows: 2         gridlayout:             id: gl             cols: 2             label:                 text: 'prix : '             label:                 text: 'in euros'          gridlayout:             cols: 2             button:                 text: 'ajouter'             button:                 text: 'quitter'                 on_press: root.manager.current = 'menu' 

result be:

kivy labels


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -