From e52bbef1c4cf260339183bef2154bea153ebcf64 Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Mon, 14 Dec 2020 15:20:40 -0800 Subject: [PATCH] added button to clear the buffer --- src/main.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main.py b/src/main.py index c7657fa..9cb8ec7 100644 --- a/src/main.py +++ b/src/main.py @@ -60,11 +60,14 @@ class Application(Gtk.Application): actionbar = Gtk.ActionBar() paste_button = Gtk.Button.new_with_label("Paste Text") copy_button = Gtk.Button.new_with_label("Copy Text") + clear_button = Gtk.Button.new_with_label("Clear") actionbar.pack_end(copy_button) actionbar.pack_end(paste_button) + actionbar.pack_end(clear_button) paste_button.connect('clicked', self.paste_text) copy_button.connect('clicked', self.copy_text) + clear_button.connect('clicked', self.clear_text) vbox.pack_start(scroller, True, True, 0) vbox.pack_end(actionbar, False, False, 0) @@ -84,6 +87,11 @@ class Application(Gtk.Application): if text is not None: self.buffer.set_text(text, -1) + def clear_text(self, widget): + start = self.buffer.get_start_iter() + end = self.buffer.get_end_iter() + self.buffer.delete(start, end) + def main(version): app = Application() return app.run(sys.argv)