Answer the question
In order to leave comments, you need to log in
How can I write button text to a variable, not a string, in kivy?
Here is my code:
from kivy.app import App
from kivy.uix.button import Button
bag = 0
class Clicker(App):
def build(self):
return Button(text='0', font_size=45,
on_press=self. btn_press,
background_color = [0, 1, .5, .7],
background_normal = '')
def btn_press(self, btn):
btn.text = '1'
if __name__ == "__main__":
Clicker().run( )
I would like that instead of inline input of the text of the button, I entered the text in the variable button.
PS: 'The idea: to make a clicker so that after pressing the button, one is added.'
Answer the question
In order to leave comments, you need to log in
Well, get some kind of global variable, which you increase for each click, and change the text for each click. What exactly is the problem?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question