-
Notifications
You must be signed in to change notification settings - Fork 9
Create a vertical ProgressBar Widget #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a vertical ProgressBar Widget #25
Conversation
e7f9e34
to
b5524d5
Compare
b5524d5
to
73d5fca
Compare
Rename files to remove the redundant "adafruit_" prefix Add necessary "__init__.py" in package directory Update the examples to use the package direcotry name structure
Added inherited members to the widgets' docs Added missing requirement in requirements.txt
I tried running the code from
Here's where the error is occurring in the _bitmap: displayio.Bitmap # The bitmap used for the bar/value
_position: (int, int) # The (x,y) coordinates of the top-left corner
_size: (int, int) # The dimensions of the progress bar
_palette: displayio.Palette(3) # The palette to be used
_progress: float # The value to represent, between 0.0 and 100.0
_border_thickness: int # The thickness of the border around the control, in pixels
_show_margin: bool # Whether we should display a margin between the border and the value/bar
# The minimum and maximum values we can represent
_range: (int, int) or (float, float) I commented out these statements, but then I got this error in
|
Currently broken: progress display value Tested on: Matrix Portal
Thanks for those pieces of info @kmatch98. A lot of those issues are mainline "Pythonisms" that CP doesn't have or support. I'm kinda working my way through this project while also learning more Python than The latest changes should all be happy and run. However, I have some changes to make so that the bar can be displayed (currently filled with the alternate/background colour). From where I currently am, it shouldn't take too much more to get the refactor done and working. There are some other changes afterward that would be needed for quality-of-life, but I'll get to those in due time. |
Had the inheritance and calls to super() based on C#, and not actual Python. Rendering now works
35a7bd7
to
d91cc96
Compare
Still displays horizontally (for testing). Will flip to vertical rendering as the next change.
ProgressBar fully refactored VerticalProgressBar fully refactored
bdbe480
to
88a636a
Compare
I tested this out today, it does run now for me. But I am getting some extra lines drawn on it, and it doesn't seem to "unfill" itself when the progress is set back down to 0 The structural changes to split this into a module are looking good to me now. I'm going to try tinkering some to see if there is a way we can make the original import statement work as well as the new ones so that we could possibly avoid having to change any existing progress bar using project code. But i'm unsure if it can actually be done. Thank you for all of your work on this @hugodahl! I will check out the new matrix portal example this week. |
88a636a
to
e46aefb
Compare
Thanks @FoamyGuy. The bars are current artifacts from the previous fill/clear methodology. I've got changes that should fix those, I just need to reimport them from my original "proof-of-concept" changes. I've also added my current color-theory-ignorant-but-highly-visually-obvious blinka/PyGameDisplay example to make sure that we can test with some common code. |
Done. Thanks for catching this!
This is intended behaviour, since there's both a border and a margin (both 1px on each side by default). If you set the
Somehow I managed to lose my assertions in the setter of
The original examples, that is, all but the "displayio" one, will need to be updated with the new syntax. @FoamyGuy and I have gone over how we want to deal with the "legacy" class, which is why it still exists in this library. It's also why it has the "old" name of I had thought, originally, of refactoring the
I agree. These are the final little details and polishing touches, which make the difference between "Yeah, it exists" and "Woo! It exists! Let's use this!" |
Correction: It does go to 100, I was confused by the |
Changes working for initial (incrementing) direction
Handles bottom-to-top and top-to-bottom for vertical, and left-to-right as well as right-to-left for horizontal
Both horizontal and vertical widgets working. PyGameDisplay example updated for all directions Pylint checks all pass, including duplicate code
Use buttons to move bars up and down
fb67633
to
2526085
Compare
This PR is ready for review. Again. |
To merge, this may be something where we'd want to bump the version to 2.0 to indicate the significant changes included. |
This is amazing you know how much I love your vertical progress bar!!! @hugodahl Welcome to the widget world :) |
Thanks! It's taken me FAR longer than I expected or would have liked, but I did pick up a significant amount of Python in the process, which is where a lot of my time went. That and Pylint's duplicate code detection! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for all of your work on this @hugodahl
I would suggest a few small tweaks but this is looking very close to me.
I think we should include a new example that makes use of the new HorizontalProgressBar and VerticalProgressBar classes more directly.
I used this one for testing them:
import time
import board
import displayio
from adafruit_progressbar.horizontalprogressbar import HorizontalProgressBar
from adafruit_progressbar.verticalprogressbar import VerticalProgressBar
# Make the display context
splash = displayio.Group(max_size=10)
board.DISPLAY.show(splash)
# set horizontal progress bar width and height relative to board's display
h_width = board.DISPLAY.width - 40
h_height = 30
v_width = 30
v_height = 140
h_x = 20
h_y = 20
v_x = 60
v_y = 70
# Create a new progress_bar objects at their x, y locations
progress_bar = HorizontalProgressBar((h_x, h_y), (h_width, h_height), 0, 100)
vert_progress_bar = VerticalProgressBar((v_x, v_y), (v_width, v_height), 0, 200)
# Append progress_bars to the splash group
splash.append(progress_bar)
splash.append(vert_progress_bar)
current_progress = 0.0
while True:
# range end is exclusive so we need to use 1 bigger than max number that we want
for current_progress in range(0, 101, 1):
print("Progress: {}%".format(current_progress))
progress_bar.value = current_progress
vert_progress_bar.value = current_progress * 2
time.sleep(0.01)
time.sleep(0.3)
# reset to empty
progress_bar.value = 0
vert_progress_bar.value = 0
time.sleep(0.3)
It could serve as a good example script perhaps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes are looking good to me.
I've tested all of the new example scripts successfully.
Thanks again for this awesome new functionality @hugodahl
When this gets merged and released we should bump the major version number since the new version uses slightly different importing syntax that is not backward compatible with previous versions. I can make a PR to update projects in the learn guide repo to use the new import syntax as well. |
@FoamyGuy I wanted to make sure this didn't get missed. If you're going to put the PR into the Learn repo to fix the code there, I want to leave it to you to merge and release this. That way you can time it all together. |
@kattni Yep, I'll get that PR in for the learn repo tonight and I will plan to merge this at the same time when that one goes in to change the learn projects to use the new import. |
Updating https://github.com/adafruit/Adafruit_CircuitPython_ProgressBar to 2.0.0 from 1.3.8: > Merge pull request adafruit/Adafruit_CircuitPython_ProgressBar#25 from hugodahl/feature/Add-vertical-progress-bar > "Increase duplicate code check threshold "
This PR will close #21