From d4edd4986293cfaaffa28190c4c10f72d197c670 Mon Sep 17 00:00:00 2001 From: mlncn Date: Sun, 2 May 2021 11:32:18 -0400 Subject: [PATCH] Provide a reset button where, if there was text to start out with, in case it was accidentally overwritten --- prompt_window.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/prompt_window.py b/prompt_window.py index 43d81eb..f097fb4 100644 --- a/prompt_window.py +++ b/prompt_window.py @@ -10,6 +10,7 @@ class PromptWindow(Gtk.Window): if task is None: task = "" + self.orig_task = task Gtk.Window.__init__(self, title="Pomodoro Prompt") self.set_size_request(500, 100) @@ -22,7 +23,7 @@ class PromptWindow(Gtk.Window): self.add(vbox) self.entry = Gtk.Entry() - self.entry.set_text(task) + self.entry.set_text(self.orig_task) self.entry.connect("activate", self.save) vbox.pack_start(self.entry, True, True, 0) @@ -33,6 +34,11 @@ class PromptWindow(Gtk.Window): self.button_ok.connect("clicked", self.save) hbox.pack_start(self.button_ok, True, True, 0) + if task: + self.button_reset = Gtk.Button.new_with_label("Reset") + self.button_reset.connect("clicked", self.reset) + hbox.pack_start(self.button_reset, True, True, 0) + vbox.pack_start(hbox, True, True, 0) @@ -45,11 +51,14 @@ class PromptWindow(Gtk.Window): # A little concerned this might be sort of the nuclear option here. Gtk.main_quit() + def reset(self, item): + self.entry.set_text(self.orig_task) + def retrieve(self): return self.task -win = PromptWindow(task="Making money") +win = PromptWindow() win.show_all() Gtk.main() tha_task = win.retrieve()