@omz, not so important. But dialogs.list_dialog can accept a list of strings or a list of dicts. Reference back to ui.ListDataSource.
It's actually very nice, you can have associate data.
But under normal circumstances is it possible for example to set accessory_action = some_func ?
I have tried various ways. I could not get it. And maybe it's not meant to be, which is ok. But I miss so many things, I had to ask!
Eg code:
# coding: utf-8
import os, dialogs
def files_from_dir(the_dir):
return [os.path.join(the_dir, f) for f in os.listdir(the_dir) if os.path.isfile(os.path.join(the_dir, f))]
def show_filename_list(list_of_files, title = 'Choose', multiple = False ):
new_list = []
for f in list_of_files:
p, fn = os.path.split(f)
new_list.append(dict(title = fn, accessory_type = 'detail_button' ,full_file_name = f))
result = dialogs.list_dialog(title = title, items = new_list, multiple = multiple)
if result:
return result['full_file_name']
else:
return None
if __name__ == '__main__':
the_path = os.path.expanduser('~')
the_path = os.path.join(the_path, 'Documents')
test_file_list = files_from_dir(the_path)
print show_filename_list(test_file_list)