robinsiebler112
Jul 30, 2014 - 23:09
In the below code, I have a form open. Clicking on the 'search' button loads another form in the 'prompt_search' function. Interacting with that form triggers the 'search_tasks' function. If the results of the search are negative, I want to close the search dialog and display a popover stating as much. However, I get a ValueError when I try to load the last screen. How do I fix this?
def prompt_search(self, sender):
"""Prompt the user for a search string."""
self.search_dialog = ui.load_view('dialogs/search_dialog')
self.search_dialog.present('sheet')
def search_tasks(self, sender):
"""Search the task list for a task whose note or tag contains the user provided search string."""
search_string = self.search_dialog['textfield1'].text.lower()
tasks = self.tasklist.search(search_string)
if tasks:
self.search_dialog.close()
self.show_tasks(sender,tasks=tasks)
else:
self.search_dialog.close()
self.message_dialog = ui.load_view('dialogs/message_dialog')
self.message_dialog['label1'].text = 'There were no tasks containing "{}".'.format(search_string)
self.message_dialog.present('popover', popover_location = (500,500))