Python Forum
[Tkinter] tkinter progress bar for decending number - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [Tkinter] tkinter progress bar for decending number (/thread-22354.html)



tkinter progress bar for decending number - justaloser - Nov-09-2019

Hello everyone, I'm starting an app to track weight loss and other goals. I was wondering if there is a way for the tkinter progress bar to go up when the number is going down? Like the goal weight will be set and as you lose weight the progress bar will fill till you reach your goal.I would have a current weight var and goal var. is there an option for that on tkinter or do I have to figure out some kind of math trickery lol don't really have any code to post yet, just wondering how I would go about it. I'm new so please be patient with me :)


RE: tkinter progress bar for decending number - Larz60+ - Nov-10-2019

>>> starting_weight = 225
>>> 
>>> def get_progress_value(current_weight):
...     return starting_weight - current_weight
... 
>>> for current_weight in range(225, 217, -1):
...     print(f"Current weight: {current_weight}, Progress bar value: {get_progress_value(current_weight)}")
... 
Current weight: 225, Progress bar value: 0
Current weight: 224, Progress bar value: 1
Current weight: 223, Progress bar value: 2
Current weight: 222, Progress bar value: 3
Current weight: 221, Progress bar value: 4
Current weight: 220, Progress bar value: 5
Current weight: 219, Progress bar value: 6
Current weight: 218, Progress bar value: 7
>>>