Reputation: 127
I wish button1 to edit Label 'etykietka' when clicked, but i don't know how. Have you got some ideas?
class Zastepstwa (App):
def build(self):
lista=WebOps().getList()
layout = BoxLayout(orientation='vertical')
etykietka = Label(text='aa', font_size=10)
button1 = Button(text='aa')
button1.bind(callback)
layout.add_widget(etykietka)
layout.add_widget(button)
return layout
def callback (instance):
newLabelText='kkk'
#?
Upvotes: 3
Views: 3818
Reputation: 11
Also, make sure you have the callback function indented and directly after the build function. Otherwise the callback function won be recognized in the bind statement.
Upvotes: 1
Reputation: 5947
you need to pass your label to callback, a nice way to do it is to use the partial function
from functools import partial
change callback signature for
def callback(label, instance, *args):
label.text='kkk'
then bind the callback like this
button1.bind(on_press=partial(callback, etykieta))
that should do it.
Upvotes: 4