Get event when an item is selected in dropdown

I want to do something when an item is selected in dropdown like change the sibling component
But i don’t create dropdown and change event by design ui

class Form1(DropDownTemplate):
 def __init__(self, **properties):
  dd = Dropdown(items=['1','2'])
  dd.set_event_handler('change', self.drop_down_change())
  self.add_component(dd)

def drop_down_change(self, **event_args):
   print('something')

something just show off one time in init() , but not when change item in dd ? Something im wrong ?

Clone link:
share a copy of your app

Welcome to the forum!

When you set an event handler, what you want to pass in for the second argument is the function. You are calling the function, which is passing in the return argument. Leave off the parenthesis:

d.set_event_handler('change', self.drop_down_change)

1 Like

@jshaffstall Thank you sir. You’re absolutely right.