Thanks to visit codestin.com
Credit goes to github.com

Skip to content

If starting progress != 0.0 and not updated it gets drawn incorrectly #12

Closed
@FoamyGuy

Description

@FoamyGuy

If you pass something other than 0.0 in the constructor and then do not ever set progress again the bar will not get drawn correctly.

It's due to the newest update that added some efficiency when drawing. So older versions likely did not have this problem.

code to reproduce:

import board
import displayio
from adafruit_progressbar import ProgressBar

# Make the display context
group = displayio.Group(max_size=2)
board.DISPLAY.show(group)
x = board.DISPLAY.width // 5
y = board.DISPLAY.height // 3
progress_bar = ProgressBar(x, y, 200, 30, 0.5)
group.append(progress_bar)

while True:
    pass

Instead of the progress bar being drawn half full there is only a single line drawn in the middle.

I think the easiest fix is to change init to use 0.0 first and then set progress afterward.

The previous code produces a correct looking result if you change it like this:

progress_bar = ProgressBar(x, y, 200, 30, 0.0)
progress_bar.progress = 0.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions