def prompt_delete_account_dialog(self): """ Prompt a confirmation dialog before deleting the account. """ if self.current_account is None: self.prompt_no_account_error() return title = "Are you sure?" body = "" body += "This action cannot be undone.\n" body += "Are you sure you want to delete this account?\n" dialog = Dialog.create_dialog_helper(title, body) dialog.add_action_button("No", action=lambda *x: dialog.dismiss()) dialog.add_action_button( "Yes", action=lambda *x: self.on_delete_account_yes(dialog)) dialog.open()
def helper_test_dismiss_dialog_twice(self, app): """ If by some choice the dismiss event of a dialog created with Controller.create_dialog_helper() is fired twice, it should be handled gracefully, refs #89. """ title = "title" body = "body" # makes sure the controller has no dialog self.assertEqual(Dialog.dialogs, []) # creates one and verifies it was created dialog = Dialog.create_dialog_helper(title, body) self.assertEqual(len(Dialog.dialogs), 1) # dimisses it once and verifies it was handled dialog.dispatch('on_dismiss') self.assertEqual(Dialog.dialogs, []) # then a second time and it should not crash dialog.dispatch('on_dismiss') self.assertEqual(Dialog.dialogs, [])