logic in widget

how to properly make logic in a widget?
I need that after clicking a button in a widget, the logic that is on the button is played after clicking on another button.


Easy enough, the first button sets a boolean
The secound button has a branch statement, then you can have it do something if the boolean is true and something else or nothing if its not