omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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

    Pythonista
    7
    13
    11150
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • polymerchm
      polymerchm last edited by

      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_

      1 Reply Last reply Reply Quote 0
      • ccc
        ccc last edited by

        This is a bit overstated for non-production code but still an interesting perspective: The Most Diabolical Python Antipattern

        1 Reply Last reply Reply Quote 0
        • omz
          omz last edited by

          @polymerchm You can also use a single pair of backticks.

          1 Reply Last reply Reply Quote 0
          • ccc
            ccc last edited by

            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
            
            1 Reply Last reply Reply Quote 0
            • hecate
              hecate last edited by

              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?

              1 Reply Last reply Reply Quote 0
              • enceladus
                enceladus last edited by

                The following url has few examples and hope it helps.
                https://github.com/encela95dus/ios_pythonista_examples

                table_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

                1 Reply Last reply Reply Quote 0
                • hecate
                  hecate last edited by

                  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?

                  1 Reply Last reply Reply Quote 0
                  • enceladus
                    enceladus last edited by

                    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))
                    
                    1 Reply Last reply Reply Quote 0
                    • hecate
                      hecate last edited by

                      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!

                      cvp 1 Reply Last reply Reply Quote 0
                      • cvp
                        cvp @hecate last edited by

                        @hecate I agree, never seen did_deselect called...

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        Powered by NodeBB Forums | Contributors