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.
Simple demo of tableview logic for the novices
-
Thank you. Most helpful and much appreciated. The try: in the tableview_did_select() is very elegant.
-
Very pythonic. Thanks.
-
Underlines are treated as markers for italicized words in markdown (the formatting language for this forum) To have the underlines show, use the triple backtick formalism to enclose code thusly
_italics_
-
This is a bit overstated for non-production code but still an interesting perspective: The Most Diabolical Python Antipattern
-
@polymerchm You can also use a single pair of backticks.
-
Suggestion: Add the expected error to
except
clause.try: self.items[self.currentRow]['accessory_type'] = 'none' # un-flags current selected row except TypeError: #needed for very first selection pass
-
I realize this was written quite a long time ago, but I tried to use the code in this example and I struggle to understand how I can have both multiple select and deselect.
By changing the row
self.currentRow = row # needed for the test above
to
self.currentRow = selected = tableview.selected_rows
I manage to get to the multi-select-part, not fancy nor smart, but from there I am currently at loss.Anything someone could suggest?
-
The following url has few examples and hope it helps.
https://github.com/encela95dus/ios_pythonista_examplestable_example1,2,3,4 - tableview examples
from forum
file navigation https://github.com/dgelessus/filenav/blob/master/litenav.py
fill rows based on the characters that are entered on textfield
https://forum.omz-software.com/topic/4328/modules-of-pythonista-displayed-with-help -
That was a great resource for examples, thank you!
By multi-selection I mean that you can add and remove check-marks on several rows in the table, I couldn't that these examples adressed that... Or am I missing something? -
Do you need something like this? It uses dialog but table example would be similar to that.
import dialogs def multiple_selection_list_dialog(lst): form_list_of_dicts = [] for item in lst: form_list_of_dicts.append(dict(type = 'check', title = item, key = item, value = False)) result = dialogs.form_dialog(title = 'Multiple Selection List', fields=form_list_of_dicts) return [i for i in result if result[i]] if result else None if __name__ == '__main__': lst = ['a'+str(i) for i in range(5)] print(multiple_selection_list_dialog(lst))
-
Exactly! Lovely!
I will have to look into this in more detail but if I understand this correctly,
return [i for i in result if result[i]] if result else None
is what makes it possible to deselect?I find it a bit confusing that in the table_view_source example http://omz-software.com/pythonista/docs/ios/ui.html#tableview there is a method called
tableview_did_deselect
but I couldn't see that it was ever being called..Thank you kindly!
-
@hecate I agree, never seen did_deselect called...