Dials & Meters

This example demonstrates the versitility of the Meter widget. All of the example below were created using the same class. All of the examples below include a supplemental label using the labeltext parameter, and all but the first example use the textappend parameter to add the ‘gb’, ‘%’, and degrees symbol. Finally, all of the examples use the parameter interactive=True which turns the meter into a dial that can be manipulated directly with a mouse-click or drag. The theme used for the examples below is cosmo.

top-left

the metertype is semi which gives the meter a semi-circle arc. The meterstyle is primary.TLabel.

top-right

the stripethickness is 10 pixels to give it a segmented appearance. The meterstyle is info.TLabel.

bottom-left

the stripethickness is 2 pixels to give it a very thin segmented appearance. The meterstyle is success.TLabel.

bottom-right

this example has a custom arc, with the arcrange at 180, the arcoffset at -180 and the wedgethickness at 5 pixels in order to create a wedge style indicator that rests at the meter value. The meterstyle is danger.TLabel.

../_images/dials_and_meters.png
"""
    Author: Israel Dryer
    Modified: 2021-05-09
"""

from ttkbootstrap import Style
from ttkbootstrap.widgets import Meter

style = Style('cosmo')
root = style.master
root.title('ttkbootstrap')

m1 = Meter(metersize=180, padding=20, amountused=25, metertype='semi', labeltext='miles per hour', interactive=True)
m1.grid(row=0, column=0)

m2 = Meter(metersize=180, padding=20, amountused=1800, amounttotal=2600, labeltext='storage used', textappend='gb',
           meterstyle='info.TMeter', stripethickness=10, interactive=True)
m2.grid(row=0, column=1)

m3 = Meter(metersize=180, padding=20, stripethickness=2, amountused=40, labeltext='project capacity', textappend='%',
           meterstyle='success.TMeter', interactive=True)
m3.grid(row=1, column=0)

m4 = Meter(metersize=180, padding=20, amounttotal=280, arcrange=180, arcoffset=-180, amountused=75, textappend='°',
           labeltext='heat temperature', wedgesize=5, meterstyle='danger.TMeter', interactive=True)
m4.grid(row=1, column=1)

root.mainloop()