diff --git a/HW/timer_button/~timer_button.kicad_sch.lck b/HW/timer_button/~timer_button.kicad_sch.lck deleted file mode 100644 index 61c7f2b..0000000 --- a/HW/timer_button/~timer_button.kicad_sch.lck +++ /dev/null @@ -1 +0,0 @@ -{"hostname":"Oneill","username":"angoosh"} \ No newline at end of file diff --git a/SW/PC/Stopwatch/main.py b/SW/PC/Stopwatch/main.py new file mode 100644 index 0000000..227c60d --- /dev/null +++ b/SW/PC/Stopwatch/main.py @@ -0,0 +1,113 @@ +import gi +import threading +import time + +gi.require_version('Gtk', '4.0') +from gi.repository import Gtk, Gio, Gdk + +index = 1 +TIME = 10*60 + +class GridRow(): + def __init__(self, parent, runner, index): + self.id = runner + self.index = index + self.parent = parent + + self.grid = Gtk.Grid() + + if index % 2 == 0: + self.grid.set_name("lightgrid") + else: + self.grid.set_name("darkgrid") + + self.runid = Gtk.Label(label=str(runner), name="gridlabel") + self.runid.set_justify(2) + self.runid.set_width_chars(10) + + self.runb = Gtk.Label(label='00:00', name="gridlabel") + self.runb.set_hexpand(1) + + self.grid.attach(self.runid, 0, 0, 1, 1) + self.grid.attach(self.runb, 1, 0, 1, 1) + + parent.grid.attach(self.grid, 0, index, 2, 1) + + countdown=threading.Thread(target=self.updateTime) + countdown.start() + + def printIndex(self, button): + print(self.index) + + def updateTime(self): + t = TIME + while t: + mins, secs = divmod(t, 60) + timer = '{:02d}:{:02d}'.format(mins, secs) + self.runb.set_label(timer) + time.sleep(1) + t -= 1 + if t == 10: + if self.grid.get_name() == "lightgrid": + self.grid.set_name("lredgrid") + else: + self.grid.set_name("dredgrid") + + GridWindow.remRow(self.parent) + +class GridWindow(Gtk.ApplicationWindow): + def __init__(self, **kargs): + super().__init__(**kargs, title='Alkator Clock') + + css_provider = Gtk.CssProvider() + css_provider.load_from_file(Gio.File.new_for_path("style.css")) + Gtk.StyleContext.add_provider_for_display(Gdk.Display.get_default(), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) + + button1 = Gtk.Button(label='addrow') + button2 = Gtk.Button(label='rmrow') + + button1.connect("clicked", self.arb) + button2.connect("clicked", self.rrb) + + self.runners = [] + + self.grid = Gtk.Grid() + self.grid.attach(button1, 0, 0, 1, 1) + self.grid.attach(button2, 1, 0, 2, 1) + + self.set_child(self.grid) + + def arb(self, button): + global index + self.runners.append(GridRow(self, index, index)) + #self.addRow(index,index) + index += 1 + + def rrb(self, button): + global index + self.remRow() + + def addRow(self, runner, index): + runid = Gtk.Label(label=str(runner)) + runb = Gtk.Button(label='time_placeholder') + + self.grid.attach(runid, 0, index, 1, 1) + self.grid.attach(runb, 1, index, 1, 1) + + def remRow(self): + global index + if index > 1: + self.grid.remove_row(1) + index -= 1 + + +def on_activate(app): + # Create window + win = GridWindow(application=app) + win.present() + + +app = Gtk.Application(application_id='com.example.App') +app.connect('activate', on_activate) + +app.run(None) \ No newline at end of file diff --git a/SW/PC/Stopwatch/style.css b/SW/PC/Stopwatch/style.css new file mode 100644 index 0000000..abad6a2 --- /dev/null +++ b/SW/PC/Stopwatch/style.css @@ -0,0 +1,20 @@ +#lightgrid { + background-color: #F0F0F0; +} + +#darkgrid { + background-color: #D0D0D0; +} + +#lredgrid { + background-color: #FF8888; +} + +#dredgrid { + background-color: #FF6666; +} + +#gridlabel { + font-size: 16pt; + font-weight: bold; +}