Button(parent, options)
activebackground: Background color when the button is under the cursor.
activeforeground: Foreground color when the button is under the cursor.
anchor: Specifies the position of the content (text or image) inside the button.
bd or borderwidth: Width of the border around the outside of the button
bg or background: Normal background color.
command: Function or method to be called when the button is clicked.
cursor: Selects the cursor to be shown when the mouse is over the button.
text: Text displayed on the button.
disabledforeground: Foreground color is used when the button is disabled.
fg or foreground: Normal foreground (text) color.
font: Text font to be used for the button's label.
height: Height of the button in text lines
highlightbackground: Color of the focus highlight when the widget does not have focus.
highlightcolor: The color of the focus highlight when the widget has focus.
highlightthickness: Thickness of the focus highlight.
image: Image to be displayed on the button (instead of text).
justify: tk.LEFT to left-justify each line; tk.CENTER to center them; or tk.RIGHT to right-justify.
overrelief: The relief style to be used while the mouse is on the button; default relief is tk.RAISED.
padx, pady: padding left and right of the text. / padding above and below the text.
width: Width of the button in letters (if displaying text) or pixels (if displaying an image).
underline: Default is -1, underline=1 would underline the second character of the button's text.
width: Width of the button in letters
wraplength: If this value is set to a positive number, the text lines will be wrapped to fit within this length.
import tkinter as tk
def button_clicked():
print("Button clicked!")
root = tk.Tk()
# Creating a button with specified options
button = tk.Button(root,
text="Click Me",
command=button_clicked,
activebackground="blue",
activeforeground="white",
anchor="center",
bd=3,
bg="lightgray",
cursor="hand2",
disabledforeground="gray",
fg="black",
font=("Arial", 12),
height=2,
highlightbackground="black",
highlightcolor="green",
highlightthickness=2,
justify="center",
overrelief="raised",
padx=10,
pady=5,
width=15,
wraplength=100)
button.pack(padx=20, pady=20)
root.mainloop()
######################################################
# import tkinter module
from tkinter import *
# Following will import tkinter.ttk module and
# automatically override all the widgets
# which are present in tkinter module.
from tkinter.ttk import *
# Create Object
root = Tk()
# Initialize tkinter window with dimensions 100x100
root.geometry('200x200')
btn = Button(root, text = 'Click me !',
command = root.destroy)
# Set the position of button on the top of window
btn.pack(side = 'top',padx=20,pady=20)
root.mainloop()
# thu vien nay tao nut nhan co hieu ung
# doi mau khi re chuot ngang qua nut nhan