Answer the question
In order to leave comments, you need to log in
How to make it so that when the button is clicked, the Label changes in Python kivy urgently?
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.widget import Widget
from kivy.uix.label import Label
from kivy.uix.anchorlayout import AnchorLayout
from kivy.uix.boxlayout import BoxLayout
class myApp(App):
def build(self):
bl = BoxLayout(padding=[200, 100], spacing=30)
gl = BoxLayout(orientation = "vertical")
gl.add_widget(Label(text = 'привет ты мальчик?', font_size = 50))
bl.add_widget(Button(text = 'да', font_size = 30,
background_color = [.32,.85,.94,1]))
bl.add_widget(Button(text = 'нет', font_size = 30,
background_color = [1 ,0 ,0, 1]))
gl.add_widget( bl)
return gl
if __name__ =="__main__":
myApp().run()
Answer the question
In order to leave comments, you need to log in
#-*- coding: utf-8 -*-
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.widget import Widget
from kivy.uix.label import Label
from kivy.uix.anchorlayout import AnchorLayout
from kivy.uix.boxlayout import BoxLayout
class myApp(App):
def build(self):
gl = BoxLayout(orientation = "vertical", padding=[200, 100], spacing=30)
self.lbl = Label(text = 'привет ты мальчик?', font_size = 50)
gl.add_widget(self.lbl)
gl.add_widget(Button(text = 'да', font_size = 30, background_color = [.32,.85,.94,1], on_press=self.update_label))
gl.add_widget(Button(text = 'нет', font_size = 30, background_color = [1 ,0 ,0, 1]))
return gl
def update_label(self, instance):
self.lbl.text = "Привет МАЛЬЧИК"
if __name__ =="__main__":
myApp().run()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question