Button Tkinter | Python 3
In this tutorial, we are going to see how to use Button widget in Tkinter. The Button widget is used to add buttons to a Python application. These buttons can display text or images that translate their function. You can attach a function or a method to a button that is called automatically when you click on the button.

[st_adsense]
Syntax:
Here is the syntax to create this widget:
btn = Button ( master, option = value, ... )
Parameters:
- master : This represents the parent window.
- options : Options can be used as comma separated key-value pairs. See the following example:
[st_adsense]
Example:
import tkinter from tkinter import messagebox gui = tkinter.Tk() def msgCallBack(): messagebox.showinfo("StackHowTo", "Welcome to StackHowTo!") btn = tkinter.Button(gui, text ="Click here!", command = msgCallBack) btn.pack() gui.mainloop()
Output:

[st_adsense]