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
-
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.
-
@AtomBombed , this thread maybe useful
https://forum.omz-software.com/topic/2462/dialogs-module-extending-it -
@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.
-
@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. -
@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?
-
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.
-
@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.
-
@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.
-
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.
-
@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.
-
you problem is on line 29.
actually, if you gist your code, someone might be able to help....