
interactive=True, so when the value of any meter i.e amountusedvar is changed by mouse, it triggers the respective function by using the trace method.
m1.amountusedvar.trace("w", my_upd1) # Trigger on change of value
m2.amountusedvar.trace("w", my_upd2)
More about trace()
def my_upd1(*args): # When Meter1 is updated
m2["amountused"] = m1["amountused"] # m2 is updated
def my_upd2(*args): # When Meter2 is updated
m1["amountused"] = m2["amountused"] # m1 is updated
import ttkbootstrap as ttk
from ttkbootstrap.constants import *
my_w = ttk.Window()
my_w.geometry("500x250")
def my_upd1(*args): # When Meter1 is updated
m2["amountused"] = m1["amountused"]
def my_upd2(*args): # When Meter2 is updated
m1["amountused"] = m2["amountused"]
m1 = ttk.Meter(
my_w,
amountused=25,
metersize=225,
meterthickness=30,
interactive=True,
)
m1.grid(row=0, column=0, padx=10, pady=10)
m2 = ttk.Meter(
my_w,
amountused=25,
metersize=225,
meterthickness=30,
interactive=True,
bootstyle=SUCCESS
)
m2.grid(row=0, column=1, padx=10, pady=10)
m1.amountusedvar.trace("w", my_upd1) # Trigger on change of value
m2.amountusedvar.trace("w", my_upd2)
my_w.mainloop()
Ttkbootstrap Meter bootstyle option using range Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.
05-04-2025 | |
| Is there any possibility to add a column of checkboxes ? | |