<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def OnSearchFlag(self, event):
 """Event handler for search flag toggle buttons"""


        for label in self.search_options_buttons:
            button_id = self.label2id[label]
            if button_id == event.GetId():
                if event.IsChecked():
                    self.search_options.append(label)
                else:
                    flag_index = self.search_options.index(label)
                    self.search_options.pop(flag_index)

        event.Skip()