Closed paul-1 closed 6 months ago
Hi Paul, your proposal is correct: Accoring to the PIL documentation, indeed X2 must be >= X1
The strange thing is that it has worked for so long the way it is. I just wanted to check what happens when x2<x1:
if __name__ == "__main__":
"""the main function can be used to test the display. """
import time
display.set_backlight(1) # display backlight is set on
print("barLength:", "\tpercent:", "\tfilledPixels:", "\tfilledPixels-(x+gap):")
for i in range(-10,101):
display.display_progress_bar(i, scrambling=False)
if i in (-1,0,1,100):
time.sleep(10)
else:
time.sleep(0.05)
The initial printout is:
barLength: percent: filledPixels: filledPixels-(x+gap):
126 -10 6 -12
126 -9 7 -11
126 -8 8 -10
126 -7 9 -9
126 -6 10 -8
126 -5 12 -6
126 -4 13 -5
126 -3 14 -4
126 -2 15 -3
126 -1 16 -2
126 0 18 0
126 1 19 1
126 2 20 2
126 3 21 3
In my case, when x2<x1, the rectangles fills to the left of the (x1) origin yet not error. Could you kindly elaborate on the error you're experiencing?
My guess is that its the newer version of the pillow library. I just installed mine last weekend. The exception was added in pillow version 9.5.0
Here is the pull request that changed to an exception https://github.com/python-pillow/Pillow/pull/6978
You're right. By updating from the 8.12 I had to the latest 10.2.0 I got the error "ValueError: x1 must be greater than or equal to x0". Thank you for spotting the error and the fix.
Occasionally the first draw of the progress bar is actually at 0% complete. This causes a problem in the math to calculate how full the progress bar is. The error is that x2 is not >= x1