Python tKinter 5

Button Click Example:

We have one lable and 5 buttons, as button is clicked a message is displayed in label.


# one label and 5 buttons
# on clicking a button message will be displayed in label
from tkinter import *
window = Tk()
#window properties

window.title("Welcome to TKinter Button Event Handling")

#label properties
lbl = Label(window, text="Welcome To Python TKinter",font=("Arial Bold", 20)),y=40)

#functions required

def clicked_Amit():
    lbl.configure(text="Me Amit !!")
def clicked_Sumit():
    lbl.configure(text="Me Sumit !!")
def clicked_Kishan():
    lbl.configure(text="Me Kishan !!")
def clicked_Mohan():
    lbl.configure(text="Me Mohan !!")
def clicked_Clear():
    lbl.configure(text="Welcome To Python TKinter")

#buttons required
btn1 = Button(window, text="Amit", command=clicked_Amit),y=150)

btn2 = Button(window, text="Sumit", command=clicked_Sumit),y=150)

btn3 = Button(window, text="Kishan", command=clicked_Kishan),y=150)

btn4 = Button(window, text="Mohan", command=clicked_Mohan),y=150)

btn5 = Button(window, text="       Clear       ", command=clicked_Clear),y=200)



When button “Kishan” is clicked: