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

Skip to content

Remove max_size parameter #153

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

Merged
merged 3 commits into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ repos:
hooks:
- id: pylint_examples
name: pylint (examples code)
require_serial: true
description: Run pylint rules on "examples/*.py" files
entry: /usr/bin/env bash -c
args: ['([[ ! -d "examples" ]] || for example in $(find . -path "./examples/*.py"); do pylint --disable=missing-docstring,invalid-name $example; done)']
Expand Down
2 changes: 1 addition & 1 deletion adafruit_display_text/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def __init__(
label_direction: str = "LTR",
**kwargs,
) -> None:
super().__init__(max_size=1, x=x, y=y, scale=1, **kwargs)
super().__init__(x=x, y=y, scale=1)

self._font = font
self._ascent, self._descent = self._get_ascent_descent()
Expand Down
2 changes: 1 addition & 1 deletion adafruit_display_text/bitmap_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(self, font, **kwargs) -> None:
super().__init__(font, **kwargs)

self.local_group = displayio.Group(
max_size=1, scale=kwargs.get("scale", 1)
scale=kwargs.get("scale", 1)
) # local_group holds the tileGrid and sets the scaling
self.append(
self.local_group
Expand Down
7 changes: 2 additions & 5 deletions adafruit_display_text/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,15 @@ def __init__(self, font, **kwargs) -> None:
text = kwargs.get("text", "")

if not max_glyphs and not text:
raise RuntimeError("Please provide a max size, or initial text")
raise RuntimeError("Please provide a max_glyphs, or initial text")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may be able to get rid of max_glyphs. if I understand correctly, the reason for that restriction and parameter was the underlying Group's max_size.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's assigned to width further down so I didn't want to mess with it for now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I'll test out this change as-is, we can merge it now if good and then remove it in a followup.

it seems odd that it would use that for width without multiplying by the width of the glyph in pixels. I can poke into it a bit and try to figure out if it's needed or how to replace it with something different.

self._tab_replacement = kwargs.get("tab_replacement", (4, " "))
self._tab_text = self._tab_replacement[1] * self._tab_replacement[0]
text = self._tab_text.join(text.split("\t"))
if not max_glyphs:
max_glyphs = len(text)
# add one to max_size for the background bitmap tileGrid

# local_group will set the scale
self.local_group = displayio.Group(
max_size=max_glyphs + 1, scale=kwargs.get("scale", 1)
)
self.local_group = displayio.Group(scale=kwargs.get("scale", 1))
self.append(self.local_group)

self.width = max_glyphs
Expand Down
2 changes: 1 addition & 1 deletion examples/display_text_advance_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from adafruit_bitmap_font import bitmap_font

display = board.DISPLAY
main_group = displayio.Group(max_size=10)
main_group = displayio.Group()
MEDIUM_FONT = bitmap_font.load_font("fonts/LeagueSpartan-Bold-16.bdf")
BIG_FONT = bitmap_font.load_font("fonts/LibreBodoniv2002-Bold-27.bdf")
TIME_PAUSE = 2
Expand Down
2 changes: 1 addition & 1 deletion examples/display_text_anchored_position.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
text_area_bottom_right.anchor_point = (1.0, 1.0)
text_area_bottom_right.anchored_position = (DISPLAY_WIDTH, DISPLAY_HEIGHT)

text_group = displayio.Group(max_size=9)
text_group = displayio.Group()
text_group.append(text_area_top_middle)
text_group.append(text_area_top_left)
text_group.append(text_area_top_right)
Expand Down
2 changes: 1 addition & 1 deletion examples/display_text_background_color_padding.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
text.append("MONSTER quops\nnewline quops") # with newline

display.auto_refresh = True
myGroup = displayio.Group(max_size=6)
myGroup = displayio.Group()
display.show(myGroup)

text_area = []
Expand Down
4 changes: 2 additions & 2 deletions examples/display_text_label_vs_bitmap_label_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@

print("bitmap_label used: {} memory".format(bitmap_label_start - bitmap_label_end))

bmap_group = displayio.Group(max_size=4) # Create a group for displaying
bmap_group = displayio.Group() # Create a group for displaying
bmap_group.append(bmap_label1)
bmap_group.append(bmap_label2)

Expand Down Expand Up @@ -209,7 +209,7 @@
label_end = gc.mem_free()

print("label used: {} memory".format(label_start - label_end))
label_group = displayio.Group(max_size=4) # Create a group for displaying
label_group = displayio.Group() # Create a group for displaying
label_group.append(label1)
label_group.append(label2)

Expand Down
2 changes: 1 addition & 1 deletion examples/display_text_pyportal.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

demos = ["CircuitPython = Code + Community", "accents - üàêùéáçãÍóí", "others - αψ◌"]

splash = displayio.Group(max_size=len(fonts) * len(demos))
splash = displayio.Group()
board.DISPLAY.show(splash)
max_y = 0
y = 2
Expand Down
2 changes: 1 addition & 1 deletion examples/display_text_wrap_pixels_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
display = board.DISPLAY

# Make the display context
main_group = displayio.Group(max_size=10)
main_group = displayio.Group()
display.show(main_group)

font = terminalio.FONT
Expand Down