added button to clear the buffer

This commit is contained in:
Morgan McMillian 2020-12-14 15:20:40 -08:00
parent cc2bfffcc8
commit e52bbef1c4
1 changed files with 8 additions and 0 deletions

View File

@ -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)