From a498b34dc5bf8d58722a3a47a3a3029f5b6ef44e Mon Sep 17 00:00:00 2001 From: Trygve Date: Fri, 25 Feb 2022 00:25:29 +0100 Subject: [PATCH] La til litt feedback etter generering --- xml_results_gui.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/xml_results_gui.py b/xml_results_gui.py index 2c696f8..6aac8bd 100644 --- a/xml_results_gui.py +++ b/xml_results_gui.py @@ -81,8 +81,25 @@ class MainWindow(Gtk.ApplicationWindow): self.box2.append(self.save_btn) self.save_dialog = Gtk.FileChooserNative.new(title="lagre xml resultat fil", parent=self, action=Gtk.FileChooserAction.SAVE) + + self.text_buffer = Gtk.TextBuffer() + self.info_text = Gtk.TextView.new() + self.info_text.set_editable(False) + self.info_text.set_margin_top(8) + self.mainlist.get_style_context().add_class('card') + self.info_text.set_buffer(self.text_buffer) + self.box2.append(self.info_text) + + self.viewstyle = self.info_text.get_style_context() + print(self.viewstyle.has_class('view')) + + self.save_dialog.connect("response", self.save_xml) self.save_btn.connect("clicked", self.show_save_dialog) + self.toast_overlay = Adw.ToastOverlay() + self.box2.append(self.toast_overlay) + self.save_toast = Adw.Toast.new('Fil lagra') + self.save_toast.set_timeout(8) def show_cnf_dialog(self, button): @@ -95,7 +112,6 @@ class MainWindow(Gtk.ApplicationWindow): self.save_dialog.show() def sel_cnf(self, dialog, response): - print('test') if response == Gtk.ResponseType.ACCEPT: file = dialog.get_file() filename = file.get_path() @@ -128,6 +144,22 @@ class MainWindow(Gtk.ApplicationWindow): otime.ttime_mtr_to_class(mtr_file, runners) otime.gen_xml_result(runners, o_classes).write(filename) + runners_ok = [] + for n in runners: + if n.status() == 'OK': + runners_ok.append(n) + + runners_dsq = [] + for n in runners: + if n.status() == 'Disqualified': + runners_dsq.append(n) + + self.text_buffer.set_text(f'Antall pƄmeldte: {len(runners)} \nAntall godkjente: {len(runners_ok)} \nAntall dsq: {len(runners_dsq)}') + + self.save_toast = Adw.Toast.new('Fil lagra i: '+filename) + self.save_toast.set_timeout(8) + self.toast_overlay.add_toast(self.save_toast) + class MyApp(Adw.Application): def __init__(self, **kwargs): super().__init__(**kwargs)