Button click - Python/Kivy Tutorial - How to set up a click event - Kivy tutorial, Python tutorial

Veröffentlicht am: 27 März 2020
auf dem Kanal: HelloWorld
638
5

This is a tutorial - in pretty crappy- to maybe show people who are new to Kivy and Python how a Button can have some action after clicking.

here the code:

import kivy
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.app import App

class Grid(GridLayout):
def __init__(self):
super(Grid, self).__init__()
self.rows = 2

self.Button1 = Button(text="Klick Me")
self.Label1 = Label(text=" ")

self.add_widget(self.Button1)
self.add_widget(self.Label1)

self.Button1.bind(on_press=self.clickfunction)

def clickfunction(self, instance):
self.Label1.text=("HelloWorld")

class MyApp(App):
def build(self):
return Grid()

if __name__=="__main__":
MyApp().run()

really look for indentations -they make a lot in Python. Have a nice day all.


Auf dieser Seite können Sie das Online-Video Button click - Python/Kivy Tutorial - How to set up a click event - Kivy tutorial, Python tutorial mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer HelloWorld 27 März 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 638 Mal angesehen und es wurde von 5 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!