Two Interlinked Meters

Two interlinked Meters of Ttkbootstrap

Triggering changes in meter values

We kept the option 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()

Two interlined Ttkbootstrap Meter widgets to change synchronously when any amountused is changed #8

Functions to update

Two functions are used to update the amountused parameter. These functions are called when the value or amountusedvar option of the meter is changed. Inside this function we are updating the other Meter' amountused parameter.
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
Ttkbootstrap Meter Displaying number of chars entered in Text widget using Meter
ttkbootstrap
Monitor System Performance using ttkbootstrap Meter and psutil
Countdown Timer using ttkbootstrap Meter Typing speed test
Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com



05-04-2025

Is there any possibility to add a column of checkboxes ?




Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer