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.


    Dialogs - List Dialog

    Pythonista
    5
    11
    7676
    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.
    • AtomBombed
      AtomBombed last edited by

      How do you use the ui.ListDataSource for the dialogs.list_dialog() popup? I am trying to make it so I can see what item has been deleted from the dialog.list_dialog(). I am trying to (when the item from the table is deleted), a reminder of the same text in your reminders will be deleted. I know how to do that, I just don't know how to make the ui.ListDataSource work for the dialog popup.

      Does any of that make sense? If so, answers are much appreciated.

      Phuket2 MTcoder 2 Replies Last reply Reply Quote 0
      • Phuket2
        Phuket2 @AtomBombed last edited by

        @AtomBombed , this thread maybe useful
        https://forum.omz-software.com/topic/2462/dialogs-module-extending-it

        1 Reply Last reply Reply Quote 0
        • MTcoder
          MTcoder @AtomBombed last edited by

          @omz @AtomBombed I am finding the list_ dialog very useful. Thank you for this! I have been successful in using the ListDataSource dictionary to set titles and images. Is there anyway to activate/catch the "accessory_type" items like check mark, etc.? I can make them appear but they are inactive.

          Like Atom I have discovered the slide over "Delete" is present. It clears the dialog list item but I have no idea how to catch this action so I can use it with my data.

          Since delete is there I assume it can be used? I'd highly appreciate knowing how to use these other items. Thank you, anyone.

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

            @MTcoder You might check out tableview_delete() under http://omz-software.com/pythonista/docs/ios/ui.html#ui.TableView.data_source

            I have not played much yet with list_dialog but I know that it is based on counterparts in the ui module.

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

              @ccc @Phuket2 so far, I have not figured the answer out. Do any of you know if the dialogs.list_dialog() has an attribute like this:

              dialogs.list_dialog("Test","6items").delegate = (delegate class here)
              

              I was wondering if it would have a delegate attribute that you could set, but it doesn't work because when you select something from the list, it returns a string of the item's title that was selected, instead of the actual list_dialog item. So is there another way?

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

                list_dialogs is only about 8 lines of code, most of which is just checking arguments. This uses _ListDialogController, which simply implements a simple TableView with a ui.ListDataSource.

                copy the code from list_dialogs, _ListDialogController, and make a custom class extending ListDataSource to do what you want inside the appropriate delegate function.

                dialogs.py and ui.py can be found after enabling Show Standard Library in options, then going to Standard Libray/site-packages.

                AtomBombed 1 Reply Last reply Reply Quote 0
                • AtomBombed
                  AtomBombed @JonB last edited by

                  @JonB could you post an example? I am not exactly following you. I am at where you said to copy, but do you want me to put the class in the program file I am writing, or right by where the item I am copying? Just a bit lost. Sorry.

                  Would I put it in the file after copying it, and making edits when pasted in the file, and then when I do it, I put a delegate attribute at the end? Like this:

                  import dialogs
                  
                  # Put the copied class from the site-packages in the library.
                  
                  dialogs.list_dialog("Hello World","Test").delegate = # copied class here?
                  

                  Would this make sense? It does for me, but the .delegate doesn't work because it turns into a string when it's tapped on.

                  Phuket2 1 Reply Last reply Reply Quote 0
                  • Phuket2
                    Phuket2 @AtomBombed last edited by

                    @AtomBombed , if you look at the thread I sent before that is the example you are looking for as far as I can see. In my opinion, for the list dialog, rather than digging into it, you would be far better off just to use the TableView yourself with the ListDataSource. I think it would be much easier and you get more experience using the ui.TableView. The mistake I made before, was thinking that the ListDataSource was very limited, but it's not. You can also subclass it.

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

                      Read the code for dialogs.list_dialog. The read the code for dialogs._ListDialogController. Then, read the code for ui.ListDataSource.

                      Armed with that knowledge, you will see that none of these have a delegate attribute. A TableView has a delegate, which is set to a ListDataSource. The ListDataSource is the delegate...you need to make a new class that extends ListDataSource, but overrides the delegate methods you are interested in. Then use that instead of ListDataSouece in your custom dialog controller. Then use your custom dialog controller in your custom list_dialog.

                      AtomBombed 1 Reply Last reply Reply Quote 0
                      • AtomBombed
                        AtomBombed @JonB last edited by

                        @JonB okay. I have been doing that, and I got pretty dang close, but it ended up just sitting in my code not doing anything. It didn't work, but it returned no errors.

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

                          you problem is on line 29.

                          actually, if you gist your code, someone might be able to help....

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