pip install ttkboostrap
Show buttons with bootstrap stylesheetimport ttkbootstrap as ttk
from ttkbootstrap.constants import *
my_w = ttk.Window()
my_w.geometry("400x150") # width and height of the window
b1 = ttk.Button(my_w, text="Button Success", bootstyle=SUCCESS)
b1.grid(row=0, column=0, padx=30, pady=30)
b1 = ttk.Button(my_w, text="Button Primary", bootstyle=PRIMARY)
b1.grid(row=0, column=1, padx=30, pady=30)
my_w.mainloop()
import ttkbootstrap as ttk
from ttkbootstrap.constants import *
my_w = ttk.Window()
my_w.geometry("520x200")
c=0
for my_style in my_w.style.colors: # List of styles
b = ttk.Button(my_w, text=my_style, bootstyle=my_style)
b.grid(row=1, column=c, padx=2, pady=20)
b = ttk.Button(my_w, text=my_style, bootstyle=(my_style, OUTLINE))
b.grid(row=2, column=c, padx=2, pady=20)
c = c + 1
my_w.mainloop()
import ttkbootstrap as ttk
from ttkbootstrap.constants import *
my_w = ttk.Window()
my_w.geometry("800x800")
my_themes=my_w.style.theme_names() # Lit of available themes
my_w.style.theme_use('darkly') # Use or set this theme
print(my_w.style.theme_use()) # name of currently used theme
my_w.mainloop()
from tkinter.font import nametofont
default_font = nametofont("TkDefaultFont")
default_font.configure(family="Times",size=14,weight='bold')
import ttkbootstrap as ttk
from ttkbootstrap.constants import *
my_w = ttk.Window()
my_w.geometry("950x500")
#
my_themes = my_w.style.theme_names() # List of available themes
my_str = ttk.StringVar(value=my_w.style.theme_use()) # default selection of theme
r, c = 0, 0 # row=0 and column =0
for values in my_themes: # List of available themes
b = ttk.Radiobutton(
my_w, text=values, variable=my_str, value=values, command=lambda: my_upd()
) # Radio buttons with themes as values
b.grid(row=r, column=c, padx=5, pady=20)
c = c + 1 # increase column by 1
if c > 8: # One line complete so change the row and column values
r, c = r + 1, 0
c, r = 0, r + 1
for my_style in my_w.style.colors: # List of styles
b = ttk.Button(my_w, text=my_style, bootstyle=my_style)
b.grid(row=r, column=c, padx=1, pady=20)
b = ttk.Button(my_w, text=my_style, bootstyle=(my_style, OUTLINE))
b.grid(row=r + 1, column=c, padx=1, pady=20)
m1 = ttk.Meter(
subtextstyle=my_style, metersize=100, amountused=65, bootstyle=my_style
)
m1.grid(row=r + 2, column=c)
fg = ttk.Floodgauge(value=75, bootstyle=my_style)
fg.grid(row=r + 3, column=c, padx=1, pady=20)
# de=ttk.DateEntry(bootstyle=color)
# de.grid(row=r+4,column=c,padx=1,pady=20)
c = c + 1
def my_upd():
my_w.style.theme_use(my_str.get())
my_w.mainloop()
Checkbutons | Checkbuttons as Buttons and toggle switches. |
ColorChooserDialog | Colour selection dialog box. |
Tableview | Showing Tabular data, |
Meter | Radial meter that can be used to show progress. |
Floodgauge | A progress indicator of any process. |
DateEntry | Select Date from Calendar. |
ToolTip | Showing help text in Popup window when mouse is hovering over the widget |
toast | Popup window for temporary alerts or messages. |
27-12-2022 | |
While running the ttkbootstrap code , i am getting the colors the first time. When i am again running the code, i am not getting the colors for SUCCESS, PRIMARY and so on. |
08-01-2023 | |
Just copy the above code and try. How you are running the code again ? Are you sure you are using the loop second time ? It should work. |
17-10-2023 | |
pourquoi select_item ne fonctionne pas dans ttkbootstrap python? |