Skip to content

Commit add940a

Browse files
Kevin MatochaKevin Matocha
Kevin Matocha
authored and
Kevin Matocha
committed
Update docs and pylint fixes
1 parent 70b8ad9 commit add940a

7 files changed

+270
-29482
lines changed

displayio_scrollbox.py

+232-163
Large diffs are not rendered by default.

docs/conf.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@
2525
# Uncomment the below if you use native CircuitPython modules such as
2626
# digitalio, micropython and busio. List the modules you use. Without it, the
2727
# autodoc module docs will fail to generate with a warning.
28-
# autodoc_mock_imports = ["digitalio", "busio"]
28+
autodoc_mock_imports = [
29+
"displayio",
30+
"fontio",
31+
"terminalio",
32+
"bitmaptools",
33+
"adafruit_display_text",
34+
"adafruit_displayio_layout",
35+
]
2936

3037

3138
intersphinx_mapping = {

examples/displayio_scrollbox_simpletest.py renamed to examples/import displayio_scrollbox.py

+29-36
Original file line numberDiff line numberDiff line change
@@ -3,75 +3,68 @@
33

44
# Example demonstrating the CircuitPython ScrollBox widget for vertical scrolling of text.
55

6-
import displayio_scrollbox
7-
8-
import gc
96
import board
7+
import math
108
import time
11-
import displayio
12-
import fontio
139
import terminalio
1410

15-
from adafruit_bitmap_font import bitmap_font
16-
17-
import math
11+
import displayio_scrollbox
1812

19-
display=board.DISPLAY
13+
display = board.DISPLAY
2014

2115
text_string = "CircuitPython is a programming language designed to simplify experimenting and learning to code on low-cost microcontroller boards."
22-
text_string = text_string+("\n\nWith CircuitPython, there are no upfront desktop downloads needed. Once you get your board set up, open any text editor, and start editing code. It's that simple.")
16+
text_string = text_string + (
17+
"\n\nWith CircuitPython, there are no upfront desktop downloads needed. Once you get your board set up, open any text editor, and start editing code. It's that simple."
18+
)
2319
# text_string = text_string+("\n\nCreate a file, edit your code, save the file, and it runs immediately. There is no compiling or uploading needed.")
2420
# text_string = text_string+("\n\nCircuitPython is designed with education in mind. It's an easy way to start learning how to code and you get immediate feedback from the board.")
2521

26-
2722
## Base example uses the builtin monospace font: terminalio.FONT
2823
font = terminalio.FONT
2924

3025
# Initialize the scroll box
31-
my_scroll_box = displayio_scrollbox.ScrollBox(display=display,
32-
x=20, y=20,
33-
width=150, height=100,
34-
text=text_string,
35-
starting_row=0,
36-
font=font,
37-
background_color=0x333333,
38-
animation_time=1.2,
39-
x_offset=5,
40-
y_offset=5,
41-
)
26+
my_scroll_box = displayio_scrollbox.ScrollBox(
27+
display=display,
28+
x=20,
29+
y=20,
30+
width=150,
31+
height=100,
32+
text=text_string,
33+
starting_row=0,
34+
font=font,
35+
background_color=0x333333,
36+
animation_time=1.2,
37+
x_offset=5,
38+
y_offset=5,
39+
)
4240

4341
# Set the x and y positions of the ScrollBox
44-
my_scroll_box.x=(display.width - my_scroll_box.width)//2
45-
my_scroll_box.y=(display.height - my_scroll_box.height)//2
42+
my_scroll_box.x = (display.width - my_scroll_box.width) // 2
43+
my_scroll_box.y = (display.height - my_scroll_box.height) // 2
4644

4745

4846
# Set the number of scrolling rows and number of steps based on the ScrollBox dimensions
4947
move_rows = my_scroll_box.height - 10
50-
steps = math.floor(my_scroll_box.max_row/move_rows)
51-
sleep_time=0.8
48+
steps = math.floor(my_scroll_box.max_row / move_rows)
49+
sleep_time = 0.8
5250

5351
# Add the ScrollBox to the display
5452
display.show(my_scroll_box)
5553

56-
while True:
54+
while True:
5755

5856
for i in range(steps):
5957
# Scroll up by the "move_rows" number of pixels
6058
my_scroll_box.scroll(ypixels=+move_rows)
6159
time.sleep(sleep_time)
6260

63-
time.sleep(2*sleep_time)
61+
time.sleep(2 * sleep_time)
62+
63+
my_scroll_box.text = "This is a shorter line now"
6464

6565
for i in range(steps):
6666
# Scroll down by the "move_rows" number of pixels
6767
my_scroll_box.scroll(ypixels=-move_rows)
6868
time.sleep(sleep_time)
6969

70-
time.sleep(2*sleep_time)
71-
72-
73-
74-
75-
76-
77-
70+
time.sleep(2 * sleep_time)

0 commit comments

Comments
 (0)