israel-dryer / ttkbootstrap

A supercharged theme extension for tkinter that enables on-demand modern flat style themes inspired by Bootstrap.
MIT License
1.98k stars 393 forks source link

Floodgauges Same Texts #441

Open bbilgic opened 1 year ago

bbilgic commented 1 year ago

Desktop (please complete the following information):

When we set same bootstyle floodgauges they have same text always.

import ttkbootstrap as ttk
from ttkbootstrap.constants import *

app = ttk.Window(size=(500, 500))

# First Gauge with value 99
gauge = ttk.Floodgauge(
    bootstyle=INFO,
    font=(None, 24, 'bold'),
    mask='Memory Used {}%',
)
gauge.pack(fill=BOTH, expand=YES, padx=10, pady=10)
gauge.configure(value=99)

# Second Gauge with value 1
gauge2 = ttk.Floodgauge(
    bootstyle=INFO,
    font=(None, 24, 'bold'),
    mask='Memory Used {}%',
)
gauge2.pack(fill=BOTH, expand=YES, padx=10, pady=10)

gauge2.configure(value=1)

app.mainloop()
  1. Setup two gauges
  2. Set them different values
  3. You will see text is same

image

Describe the bug

This issue came with text change function and it is changing all styled elements.

image

To Reproduce

No response

Expected behavior

No response

Screenshots

No response

Additional context

No response

Andermutu commented 2 weeks ago

Hi, I'm facing the same bug. Is there any fix for this?

MatthiasJaeger commented 2 weeks ago

@Andermutu: I don't know enough about tkinter and ttk to create a fix. My suspicion is that in the background the way tkinter variables are saved works a bit like a dictionary and that the FloodGauges somehow end up using the same key and hence accessing the same variable.

As a workaround for a limited number of FloodGauges: It appears that this only happens if they have the same style assigned. If the color doesn't matter using different styles works (tested). If the color matters it might be possible to create several styles that look the same and use those (untested).

Andermutu commented 1 week ago

This works: If the color matters it might be possible to create several styles that look the same and use those.