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
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here





    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 FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer