text: "Volume: {(machine|master_volume):.0%}" # 0.35 -> "35%"
expire: 2s
# show it whenever the machine var changes
widget_player:
machine_var_master_volume:
volume_display:
action: add
:.0% multiplies by 100, appends %, and shows 0 decimals (e.g., 0.35 → 35%).
Use :.1% if you want one decimal place (e.g., 35.0%).
This is straight from MPF’s Text Templates behavior: variables go in {}, and the part after the colon is standard Python’s format mini-language.
And yes, (machine|my_var) is the right token form for slide/text content; MPF documents that syntax specifically for slide widgets.
(Optional) If you want a skinny “volume bar”
MPF’s rectangle width: is in pixels, so a quick pattern is to create a fixed-height rectangle and animate its width on machine_var_master_volume using the event’s (value):
# put a bar on the slide (start at width 0)
slides:
service_overlay:
widgets:
- type: rectangle
key: volume_bar
x: left+5%
y: bottom+25%
anchor_x: left
anchor_y: middle
height: 14
width: 0
corner_radius: 3
color: "00FF00"
# increase width whenever master_volume changes
widgets:
volume_bar:
- type: rectangle
animations:
machine_var_master_volume:
- property: width
value: (value) # see note below
Then scale it to your desired max width by feeding the event a pixel value (e.g., post a companion event or compute a machine var to pixels). The animation/how-to shows using value: (value) directly from the event; rectangle width itself is documented as pixel-based.
But if all you needed was “35%” instead of “0.35”, the first snippet with:
text: "Volume: {(machine|master_volume):.0%}"
is the minimal, reliable fix. ✅
Hope that helps! —Kaydee helpers on MPF 😊