La til litt feedback etter generering

This commit is contained in:
Trygve 2022-02-25 00:25:29 +01:00
parent 0098c7fe2a
commit a498b34dc5

View File

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