diff --git a/prompt_window.py b/prompt_window.py index c277b26..bc0cae4 100644 --- a/prompt_window.py +++ b/prompt_window.py @@ -16,9 +16,6 @@ class PromptWindow(Gtk.Window): self.set_size_request(500, 100) self.set_border_width(10) - # This is needed to end the thread if the dialog is closed with the X. - self.connect("destroy", Gtk.main_quit) - vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10) self.add(vbox) @@ -45,22 +42,20 @@ class PromptWindow(Gtk.Window): self.set_title(prompt) self.show_all() - Gtk.main() def save(self, item): # Note: item is the entry directly if enter is pressed, but the button # (i guess) if the button is pressed, so we do not use it. self.task = self.entry.get_text() - # A little concerned this might be sort of the nuclear option here. - Gtk.main_quit() + self.destroy() def reset(self, item): self.entry.set_text(self.orig_task) def retrieve(self): - if self.task: + try: return self.task - else: + except AttributeError: return None # started to do conditional like this but maybe main program handles. # else if self.orig_task: @@ -68,6 +63,10 @@ class PromptWindow(Gtk.Window): def prompt(prompt=None, task=None): win = PromptWindow(prompt=prompt, task=task) + # This is needed to end the thread if the dialog is closed with the X. + win.connect("destroy", Gtk.main_quit) + win.show_all() + Gtk.main() return win.retrieve()