Skip to content

Instantly share code, notes, and snippets.

@geojeff
Created May 11, 2013 08:08
Show Gist options
  • Save geojeff/5559270 to your computer and use it in GitHub Desktop.
Save geojeff/5559270 to your computer and use it in GitHub Desktop.
def delete_data_item(self, item):
if item in self.data:
index = self.data.index(item)
if item in self.selection:
self.dispatch('on_selection_change')
self.data.remove(item)
self.dispatch('on_data_item_delete', index)
def delete_data_item_at_index(self, index):
if 0 <= index < len(self.data):
item = self.data[index]
if item in self.selection:
self.dispatch('on_selection_change')
self.data.remove(item)
self.dispatch('on_data_item_delete', index)
def add_data_item(self, item):
self.data.append(item)
self.dispatch('on_data_item_add', len(self.data)-1)
def add_data_item_at_index(self, index, item):
self.data.insert(index, item)
self.dispatch('on_data_item_add', index)
def move_data_item(self, old_index, new_index):
self.data.insert(newindex, self.data.pop(oldindex))
self.dispatch('on_data_item_move', (old_index, new_index))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment