arcrange | Arc range in degree. |
arcoffset | Offset from starting position in degree, 0 position is at 3'Oclock . |
amounttotal | The maximum value of the Arc |
amountused | Current Meter value, displayed at center if showtext is True. |
wedgesize | The length of the wedge if not equal to 0 . |
metersize | Size of one side of the Meter ( as a squre ). |
arcrange | Arc range in degree. |
bootstyle | Style keyword, options are primary, secondary, success,info,warning,danger, light, dark |
metertype | FULL or SEMI |
meterthickness | Thickness of indicator. |
showtext | True / False, Show the text. |
interactive | If True then indicator can be adjusted using Mouse |
stripethickness | If greater than 0 then striped bands with thickness is shown. |
textleft | At the left of center text. |
textright | At the right of center text. |
textfont | Font for the center text. textfont=['Times',10,'bold'] |
subtext | Supplemental text below center text. |
subtextstyle | Bootstyle colour of subtext. |
subtextfont | Font for subtext . |
stepsize | Step size of increment on Mouse interaction. |
**kwargs | Other keyword arguments. |
import ttkbootstrap as ttk from ttkbootstrap.constants import * my_w = ttk.Window() my_w.geometry("400x220") b1 = ttk.Meter( master=my_w, amountused=85, # Current value metersize=200, # Size of the meter meterthickness=30, # Thickness of the meter ring bootstyle=WARNING, # Yellow color theme ) b1.grid(row=1, column=1, padx=10, pady=10) my_w.mainloop()
b1.configure(amountused=25,interactive=True)
interactive=True
and display the same value on a Button.
b1.amountusedvar.get()
import ttkbootstrap as ttk # Import ttkbootstrap for themed widgets from ttkbootstrap.constants import * # Import bootstrap constants for styling my_w = ttk.Window() my_w.geometry("400x220") # Set window size (width x height) # Create an interactive Meter widget b1 = ttk.Meter( master=my_w, # Parent widget amountused=65.0, # Initial value (supports decimal) meterthickness=30, # Thickness of the meter ring bootstyle=WARNING, # Set the theme color to WARNING (yellow) interactive=True # Allows user to adjust the meter value manually ) b1.grid(row=1, column=1, padx=10, pady=10) # Place the meter in the grid layout # Function to update button text dynamically with decimal places def update_button_text(*args): """ This function updates the button text whenever the meter value changes. It formats the value to display 2 decimal places. """ l2.configure(text=f"Value: {b1.amountusedvar.get():.2f}") # Show value with 2 decimal places # Create a Button that displays the meter value l2 = ttk.Button( my_w, text=f"Value: {b1.amountusedvar.get():.2f}", # Initial text showing 2 decimal places bootstyle=DANGER # Set button color to DANGER (red) ) l2.grid(row=1, column=2, padx=10) # Place the button in the grid layout # Bind the meter variable to update the button text when the meter value changes b1.amountusedvar.trace("w", update_button_text) # Run the Tkinter event loop my_w.mainloop()
import ttkbootstrap as ttk
from ttkbootstrap.constants import *
my_w = ttk.Window()
my_w.geometry("720x80")
c = 0 # Column value
for my_style in my_w.style.colors: # List of styles
m1 = ttk.Meter(
subtext=my_style, subtextfont=['Times',6,'normal'],
textfont=['Times',6,'bold'], metersize=80,
amountused=65, bootstyle=my_style
)
m1.grid(row=1, column=c, padx=5)
c = c + 1
my_w.mainloop()
b1 = ttk.Meter(
my_w,
amountused=65,
meterthickness=30,
bootstyle=INFO,
interactive=True,
textfont=['Times',26,'bold'],
textright='%',
textleft='Speed',
subtext='Performance',
subtextfont=['Times',10,'normal'],
subtextstyle=SECONDARY
)
gap_sec=1000 # milliseconds
my_w.after(gap_sec,my_second)
Full code is here
import ttkbootstrap as ttk
from ttkbootstrap.constants import *
my_w = ttk.Window()
my_w.geometry("220x260") # width and height
m1 = ttk.Meter(
my_w,
amounttotal=59,
amountused=0,
meterthickness=20,
bootstyle=INFO,
metersize=200,
stripethickness=6
)
m1.grid(row=1, column=1, padx=5, pady=10)
count = 0
gap_sec = 10 # Time delay in milliseconds
def my_second():
global count
if count <= 59:
m1['amountused'] = count # update meter value
count = count + 1
my_w.after(gap_sec, my_second) # time delay in milliseconds
else:
count = 0
b1 = ttk.Button(my_w, text='Start', command=my_second)
b1.grid(row=2, column=1)
my_w.mainloop()
The Meter widget in ttkbootstrap provides a visually appealing way to display progress, gauge values, or performance metrics in your Tkinter applications. It supports various styles and themes, making it a great addition to modern GUI designs.
Visit Documentation