Python Tkinter multiple buttons event handling example
In this program, you will learn how to create a Tkinter multiple buttons event handling example in Python.
b1 = Button(tk, text="One", command=display1).place(x=100, y=100)
b2 = Button(tk, text="Two", command=display2).place(x=200, y=100)
Example: How to create a Tkinter multiple buttons event handling example in Python
from tkinter import *
from tkinter import messagebox
def display1():
messagebox.showinfo("Xiith.com", "You clicked 1")
def display2():
messagebox.showinfo("Xiith.com", "You clicked 2")
def display3():
messagebox.showinfo("Xiith.com", "You clicked 3")
def display4():
messagebox.showinfo("Xiith.com", "You clicked 4")
tk = Tk()
tk.geometry("600x500")
b1 = Button(tk, text="One", command=display1).place(x=100, y=100)
b2 = Button(tk, text="Two", command=display2).place(x=200, y=100)
b3 = Button(tk, text="Three", command=display3).place(x=300, y=100)
b4 = Button(tk, text="Four", command=display4).place(x=400, y=100)
tk.mainloop()