Meter widget of ttkbootstrap

Ttkbootstrap Meter
A radial meter that can be used to show progress of a process or can be used as input to the process.
arcrangeArc range in degree.
arcoffsetOffset from starting position in degree, 0 position is at 3'Oclock .
amounttotalThe maximum value of the Arc
amountusedCurrent Meter value, displayed at center if showtext is True.
wedgesizeThe length of the wedge if not equal to 0 .
metersizeSize of one side of the Meter ( as a squre ).
arcrangeArc range in degree.
bootstyleStyle keyword, options are
primary, secondary, success,info,warning,danger, light, dark
metertype FULL or SEMI
meterthicknessThickness of indicator.
showtextTrue / False, Show the text.
interactiveIf True then indicator can be adjusted using Mouse
stripethicknessIf greater than 0 then striped bands with thickness is shown.
textleftAt the left of center text.
textrightAt the right of center text.
textfontFont for the center text. textfont=['Times',10,'bold']
subtextSupplemental text below center text.
subtextstyleBootstyle colour of subtext.
subtextfontFont for subtext .
stepsizeStep size of increment on Mouse interaction.
**kwargsOther keyword arguments.

Ttkbootstrap Meter Parameters

import ttkbootstrap as ttk
from ttkbootstrap.constants import *

my_w = ttk.Window()
my_w.geometry("400x220")

b1 = ttk.Meter(
    my_w,
    amountused=85,
    metersize=200,
    meterthickness=30,
    bootstyle=WARNING,
)
b1.grid(row=1, column=1, padx=10, pady=10)

my_w.mainloop()
Ttkbootstrap Radial Meter widget to display or read Progress of a process

configure()

We can manage parameters by using configure().
b1.configure(amountused=25,interactive=True)

Displaying amountused value

Ttkbootstrap Meter amountusedvar
We will update the Meter by using mouse by keeping the parameter interactive=True and display the same value on a Button.
import ttkbootstrap as ttk
from ttkbootstrap.constants import *

my_w = ttk.Window()
my_w.geometry("400x220") # width and height 

b1 = ttk.Meter(
    my_w,
    amountused=65,
    meterthickness=30,
    bootstyle=WARNING,
    interactive=True
)
b1.grid(row=1, column=1, padx=10, pady=10)

l2=ttk.Button(my_w,textvariable=b1.amountusedvar,bootstyle=DANGER)
l2.grid(row=1,column=2,padx=10)

my_w.mainloop()

Using bootstyle parameter

Ttkbootstrap Meter colours
Inside a for loop we can add different available bootstrap style colours by using bootstyle parameter.
Check how the textfont, subtextfont parameters are used.
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()

textfont, textleft, textright, subtext, subtextfont, subtextstyle

Ttkbootstrap Meter colours
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
)

stripthickness

Ttkbootstrap Meter stripethickness with timer
We can create segments in meter, by using stripthickness to more than 0. Here is one example using one segment representing one second. We are using one 60 second Meter where the starting of the counting is triggered by click of a button. Each second one segment is added.

To trigger the function to change the value we have used one recursive timer. It takes the inputs in milliseconds and after the delay triggers the function
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 Millseconds 
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 Milli seconds 
        
    else:
        count=0
    
b1=ttk.Button(my_w,text='Start',command=my_second)
b1.grid(row=2,column=1)
my_w.mainloop()
Ttkbootstrap Meter bootstyle option using range Two Interlinked Meters 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