code: def button_clicked(self, button):
          
          if button is self.idx_ok:            
              fn = Path(self.filename)
              xp_format = self.xp_format.get_value()
              
              if self.all_types.get_value():
                  evt_type = self.event_types
              else:
                  evt_type = [
                          x.text() for x in self.idx_evt_type.selectedItems()]
                  
              if 'CSV' == xp_format:
                                  
                  self.parent.notes.annot.export_events(fn, evt_type)
              
              elif 'Brain Vision' == xp_format:
                  
                  events = []
                  for et in evt_type:                
                      events.extend(self.parent.notes.annot.get_events(name=et))
          
                  if not events:
                      self.parent.statusBar.showMessage('No events found.')
                      return
                  
                  events = sorted(events, key=lambda x: x['start'])
                  dataset = self.parent.info.dataset
                  data = ChanTime()
                  data.start_time = dataset.header['start_time']
                  data.s_freq = int(dataset.header['s_freq'])
                  
                  with fn.with_suffix('.vmrk').open('w') as f:
                      lg.info('Writing to ' + str(fn) + '.vmrk')
                      f.write(_write_vmrk(data, fn, events))
                  
              self.accept()
              
          if button is self.idx_cancel:
              self.reject()
docs: Action when button was clicked.
  
          Parameters
          ----------
          button : instance of QPushButton
              which button was pressed