tkinter ttk theme button
To create a pushbutton in a top-level window or frame named parent.
b = ttk.Button()
Button options:
1) command
A function to be called when the button is pressed.
2) compound
If you provide both image and text options, the compound option specifies the position of the image relative to the text. The value may be tk.TOP, tk.BOTTOM, tk.LEFT or tk.RIGHT.
3) cursor
The cursor that will appear when the mouse is over the button.
4) image
An image to appear on the button.
5) takefocus
By default, a ttk.Button will be included in focus traversal. To remove the widget from focus traversal, use takefocus=False.
6) text
The text to appear on the button, as a string.
7) textvariable
A variable that controls the text that appears on the button.
8) underline
If this option has a nonnegative value n, an underline will appear under the character at position n.
9) width
If the label is text, this option specifies the absolute width of the text area on the button, as a number of characters.
These options are not supported in ttk button:
activebackground
anchor
background or bg
bitmap
borderwidth or bd
cursor
default
disabledforeground
font
foreground or fg
height
highlightbackground
highlightcolor
highlightthickness
justify
overrelief
padx
pady
relief
repeatdelay
repeatinterval
state
wraplength
New method:
.invoke()
Calls the button's command callback, and returns what that function returns.
Example :
import tkinter as tk
from tkinter import ttk
root = tk.Tk()
root.geometry('300x200')
exit = ttk.Button(root, text='Exit', command=lambda: root.quit())
exit.pack(ipadx=5, ipady=5)
root.mainloop()
Comments