You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I am understanding correctly then the button instance that we are extending is never being used after being instantiated. Instead everything gets put into the self.group instance.
In user code the result of this is when we want to use a Button we have to create it and then specifically access the group property on it when we add it to the screen:
button=Button( ... )
# Add button to the display contextsplash.append(button.group)
Adding to the confusion Button itself is also a Group so this code does not throw any errors:
button=Button( ... )
splash.append(button)
But won't result in the button being added to the screen.
I think we can get rid of one of the two Group instances. I think it would make sense to keep the instance that Button is extending and use that one, getting rid of self.group. This would make Button behave more like the adafruit_display_text.Label in that the object resulting from __init__() is ready to be added to the screen, or other Groups, directly. i.e.
The Button class is extending group:
Adafruit_CircuitPython_Display_Button/adafruit_button.py
Line 59 in 4f49de1
Inside of
Button.__init__()
we are calling up toGroup.__init__()
with default params:Adafruit_CircuitPython_Display_Button/adafruit_button.py
Line 103 in 4f49de1
But we are also creating another new group and storing it at
self.group
:Adafruit_CircuitPython_Display_Button/adafruit_button.py
Line 110 in 4f49de1
Which we later append the body, outline, and text label to:
Adafruit_CircuitPython_Display_Button/adafruit_button.py
Line 176 in 4f49de1
If I am understanding correctly then the button instance that we are extending is never being used after being instantiated. Instead everything gets put into the
self.group
instance.In user code the result of this is when we want to use a Button we have to create it and then specifically access the
group
property on it when we add it to the screen:Adding to the confusion Button itself is also a Group so this code does not throw any errors:
But won't result in the button being added to the screen.
I think we can get rid of one of the two Group instances. I think it would make sense to keep the instance that Button is extending and use that one, getting rid of
self.group
. This would make Button behave more like theadafruit_display_text.Label
in that the object resulting from__init__()
is ready to be added to the screen, or other Groups, directly. i.e.The
adafruit_display_shapes
objects, andadafruit_progressbar.ProgressBar
are a few other examples that work this way.The text was updated successfully, but these errors were encountered: