MicroGui: Set visible button in Buttonlist stack

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
haybarry
Posts: 8
Joined: Mon Nov 07, 2016 10:16 am

MicroGui: Set visible button in Buttonlist stack

Post by haybarry » Sun May 15, 2022 7:08 am

Good Afternoon,

Using MicroGui with ESP32 with PSRAM and ILI9341 display

I am trying to algorithmically set the visible button in a buttonlist stack.

Firstly, is it possible? it seems to me that .value should allow me to do this

"value Optional args button=None, new_cb=False. The button arg, if provided, should be a button in the set. If supplied and the button is not active the currency changes to the supplied button, which is displayed. By default the callback of the previous button is run, otherwise the callback of the newly displayed button."

But what is the name of the button in the set if the buttons have been created by .add_button?

my code
lightswitch[z] = ButtonList(my_callbacktest)
for t in btable:
lightswitch[z].add_button(wri, slocation[z][1]+15, labcol-6, shape=RECTANGLE, height=16, width=16, text=slocation[z][0], **t)

Thank you for your consideration.

Cheers

Barry

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: MicroGui: Set visible button in Buttonlist stack

Post by pythoncoder » Sun May 15, 2022 8:02 am

The add_button method returns the button object (as stated in the README). This can be used as the argument to value. You don't need a name for a button (they don't have one) - you use the Button instance.
Peter Hinch
Index to my micropython libraries.

haybarry
Posts: 8
Joined: Mon Nov 07, 2016 10:16 am

Re: MicroGui: Set visible button in Buttonlist stack

Post by haybarry » Wed May 18, 2022 5:09 am

Thank you Peter

Post Reply