start(), stop(), step() of Floodgauge widget

Ttkbootstrap Floodgauge start stop step methods

Floodgauge.start()

Start the autoincrement of the Floodgauge.

Floodgauge.stop()

Stop the autoincrement of the Floodgauge.

Floodgauge.step()

Step increase the value of the Floodgauge.

Here is one example where on click of button we can call the different methods to manage the Floodgauge.
import ttkbootstrap as ttk
from ttkbootstrap.constants import *

my_w = ttk.Window()
my_w.geometry("520x320")  # width and height

fg = ttk.Floodgauge(
    bootstyle=INFO,
    mask="Progress {}%",
    value=10,
    length=500,
   )
fg.grid(row=1, column=1, padx=10, pady=50, columnspan=4)

b1 = ttk.Button(my_w, text="Start", 
    command=lambda:fg.start(), bootstyle=SUCCESS)
b1.grid(row=2, column=1, padx=10, pady=40)

b2 = ttk.Button(my_w, text="Stop", 
    command=lambda:fg.stop(), bootstyle=DANGER)
b2.grid(row=2, column=2, padx=10, pady=40)
    
b3 = ttk.Button(my_w, text="Jump",
     command=lambda:fg.step(5), bootstyle=PRIMARY)
b3.grid(row=2, column=3, padx=10, pady=40)

b4 = ttk.Button(my_w, text="Reset",
     command=lambda:fg.configure(value=10), bootstyle=WARNING)
b4.grid(row=2, column=4, padx=10, pady=40)

my_w.mainloop()


Floodgauge start() stop() & step() method to manage autoincrement & update bootstyle based on value


Managing colour by bootstyle

Ttkbootstrap Floodgauge Managing colour by bootstyle
We will update the colour or style of the Floodgauge based on the value. Here we will create different colour ranges and accordingly update the bootstyle parameter value.
To trigger the change we will use trace() method of the Floodgauge variable.
Here once the fg.variable value changes, it will trigger the function my_upd().
fg.variable.trace('w',my_upd)
Here is the code for my_upd()
def my_upd(*args):
    if fg.variable.get()<25:
        fg.configure(bootstyle=INFO)
    elif fg.variable.get()<50:
        fg.configure(bootstyle=SUCCESS)
    elif fg.variable.get()<80:
        fg.configure(bootstyle=WARNING)
    else:
        fg.configure(bootstyle=DANGER)
fg.variable.trace('w',my_upd)
Full code with buttons to start, stop, jump and Reset is here .
import ttkbootstrap as ttk
from ttkbootstrap.constants import *

my_w = ttk.Window()
my_w.geometry("520x320")  # width and height

fg = ttk.Floodgauge(
    bootstyle=INFO,
    mask="Progress {}%",
    value=10,
    length=500,
)
fg.grid(row=1, column=1, padx=10, pady=50, columnspan=4)

b1 = ttk.Button(my_w, text="Start", command=lambda: fg.start(), bootstyle=SUCCESS)
b1.grid(row=2, column=1, padx=10, pady=40)

b2 = ttk.Button(my_w, text="Stop", command=lambda: fg.stop(), bootstyle=DANGER)
b2.grid(row=2, column=2, padx=10, pady=40)

b3 = ttk.Button(my_w, text="Jump", command=lambda: fg.step(5), bootstyle=PRIMARY)
b3.grid(row=2, column=3, padx=10, pady=40)

b4 = ttk.Button(
    my_w, text="Reset", command=lambda: fg.configure(value=10), bootstyle=WARNING
)
b4.grid(row=2, column=4, padx=10, pady=40)


def my_upd(*args):
    if fg.variable.get() < 25:
        fg.configure(bootstyle=INFO)
    elif fg.variable.get() < 50:
        fg.configure(bootstyle=SUCCESS)
    elif fg.variable.get() < 80:
        fg.configure(bootstyle=WARNING)
    else:
        fg.configure(bootstyle=DANGER)


fg.variable.trace("w", my_upd)
my_w.mainloop()
Ttkbootstrap Meter bootstyle option using range Two Interlinked Meters Displaying number of chars entered in Text widget using Floodgauge
ttkbootstrap
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







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