Server Applet: def setup_events(self) Call? Button.on_click(button handler) now towkring.

Hi,

I’m trying to build an applet, modeled off of the stock_applet example. I’m having some trouble setting up the on_click(button_handler) for the Button that I’m trying to incorporate. I put the on_click(button_handler) within the setup events:

if self.refresh_button:

self.refresh_button.on_click(self.button_handler())

mirroring the setup of the Select types. When I click the button, I see in my cmd that the button handler is successfully referenced, the tasks are carried out, and then the curdoc().add(self) seems to hit. However, at the last minute, I get a TypeError ‘NoneType’ object is not callable, referencing line 17 in buttons.py

self.on_change(‘clicks’, lambda obj, attr, old, new: handler())

and that the server actually goes back, and re-creates the applet by calling make_object() again. This completely re-sets my applet, vs the Select buttons, which just change the appropriate settings. I get the same issues, even when I have my button handler just print a logging message. I’ve attached a screenshot of the output, including my logging messages.

During my investigation, I noticed that my def setup_events is called twice when my dashboard is loaded: Once right after def create(), and once after app = Dashboard.create() in def make_object().

How is def setup_events(self) being called? I’m assuming it’s from the server side, but wasn’t able to find the specific reference. For the on_change()/on_click() events for the Selects and Buttons, it seems to me that they should both be included in the setup_event as the behavior is similar. However, the button returns a NoneType issue, while the Select doesn’t. Why is this?