Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Table delete bug?
-
I was trying to build a custom table data source and ran into a problem. It seems that calling delete_rows with a tuple argument doesn't work unless the tuple is (0,0). Here is a simplified example (it fails to delete anything but the first item):
import ui class MyTableViewDataSource (object): data = [['one','two'],['three','four']] def tableview_number_of_sections(self, tableview): return len(self.data) def tableview_number_of_rows(self, tableview, section): return len(self.data[section]) def tableview_cell_for_row(self, tableview, section, row): cell = ui.TableViewCell() cell.text_label.text = self.data[section][row] return cell def tableview_title_for_header(self, tableview, section): return ('Alpha','Beta')[section] def tableview_can_delete(self, tableview, section, row): return True def tableview_delete(self, tableview, section, row): del self.data[section][row] tableview.delete_rows([(section,row)]) def tableview_move_row(self, tableview, from_section, from_row, to_section, to_row): pass def tableview_did_select(self, tableview, section, row): pass def tableview_did_deselect(self, tableview, section, row): pass def tableview_title_for_delete_button(self, tableview, section, row): return 'Remove' tab = ui.TableView() tab.flex = 'WHTBLR' src = MyTableViewDataSource() tab.data_source = src tab.delegate =src tab.present('sheet')
-
Oddly, you can delete the last row if you deleted the first row first.....
Looks like you can use
reload
, rather thandelete_rows
. No animation, but functional.