Home » Python » Tkinter Examples » Button
Python Tkinter Button Examples
Example 1
from tkinter import *
root = Tk()
myButton = Button(root, text="Hey Click Me!")
myButton.pack()
root.mainloop()
Disabling Button
from tkinter import *
root = Tk()
myButton = Button(root, text="Hey Click me!", state=DISABLED)
myButton.pack()
root.mainloop()
Showing Buttons in a grid
from tkinter import *
root = Tk()
myButton1 = Button(root, text="Button 1")
myButton2 = Button(root, text="Button 2")
myButton1.grid(row=0, column=0)
myButton2.grid(row=0, column=1)
root.mainloop()
Setting Padding in Button
from tkinter import *
root = Tk()
myButton = Button(root, text="Hey Click Me!", padx=55, pady=55)
myButton.pack()
root.mainloop()