Page 1 of 1

MicroGui: Set visible button in Buttonlist stack

Posted: Sun May 15, 2022 7:08 am
by haybarry
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

Re: MicroGui: Set visible button in Buttonlist stack

Posted: Sun May 15, 2022 8:02 am
by pythoncoder
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.

Re: MicroGui: Set visible button in Buttonlist stack

Posted: Wed May 18, 2022 5:09 am
by haybarry
Thank you Peter