From 5c3cbde856414fda64a8a07b48327093ac577cb2 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Thu, 30 May 2019 21:13:08 -0700 Subject: [PATCH 1/2] Fixed example to work with CP 4 and fixed index out of range error --- adafruit_button.py | 2 +- examples/display_button_simpletest.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/adafruit_button.py b/adafruit_button.py index 115fc66..50e5491 100755 --- a/adafruit_button.py +++ b/adafruit_button.py @@ -146,7 +146,7 @@ def label(self): @label.setter def label(self, newtext): - if self._label and (self.group[-1] == self._label): + if self._label and len(self.group) > 0 and (self.group[-1] == self._label): self.group.pop() self._label = None diff --git a/examples/display_button_simpletest.py b/examples/display_button_simpletest.py index 04fda4b..ace4679 100644 --- a/examples/display_button_simpletest.py +++ b/examples/display_button_simpletest.py @@ -37,8 +37,8 @@ color_palette[0] = 0x404040 bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, - position=(0, 0)) -print(bg_sprite.position) + x=0, y=0) +print(bg_sprite.x, bg_sprite.y) splash.append(bg_sprite) ########################################################################## From 00bd1cab0b7c047c06048837d1596c695e194ff1 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Thu, 30 May 2019 21:19:48 -0700 Subject: [PATCH 2/2] Removed len() from check --- adafruit_button.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_button.py b/adafruit_button.py index 50e5491..32cc0b9 100755 --- a/adafruit_button.py +++ b/adafruit_button.py @@ -146,7 +146,7 @@ def label(self): @label.setter def label(self, newtext): - if self._label and len(self.group) > 0 and (self.group[-1] == self._label): + if self._label and self.group and (self.group[-1] == self._label): self.group.pop() self._label = None