code: def delete_channel(self, chname):
          
          name = chname.lower()
  
          if len(self.channel_names) < 1:
              self.logger.error('Delete channel={0} failed. '
                                'No channels left.'.format(chname))
              return
  
          with self.lock:
              channel = self.channel[name]
  
              # Close local plugins open on this channel
              self.close_plugins(channel)
  
              try:
                  idx = self.channel_names.index(chname)
              except ValueError:
                  idx = 0
  
              # Update the channels control
              self.channel_names.remove(channel.name)
              self.channel_names.sort()
  
              self.ds.remove_tab(chname)
              del self.channel[name]
              self.prefs.remove_settings('channel_' + chname)
  
              # pick new channel
              num_channels = len(self.channel_names)
              if num_channels > 0:
                  if idx >= num_channels:
                      idx = num_channels - 1
                  self.change_channel(self.channel_names[idx])
              else:
                  self.cur_channel = None
  
          self.make_gui_callback('delete-channel', channel)
docs: Delete a given channel from viewer.