From a29c4509a316c0c77450b6fa74b96f036b0f0821 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Tue, 23 Dec 2025 09:59:50 +0100 Subject: Add structure --- app.py | 75 ------------------------------------------------------------------ 1 file changed, 75 deletions(-) delete mode 100644 app.py (limited to 'app.py') diff --git a/app.py b/app.py deleted file mode 100644 index cf4bc1d..0000000 --- a/app.py +++ /dev/null @@ -1,75 +0,0 @@ -"""Simple score counter for two teams""" - -import toga -from toga.style.pack import COLUMN, ROW - - -class ScoreCounter(toga.App): - """The main ScoreCounter application""" - - def startup(self): - """startup entry point""" - self.score_team1 = 0 - self.score_team2 = 0 - - main_box = toga.Box(direction=COLUMN) - - self.score_label1 = toga.Label( - f'Team1: {self.score_team1}', margin=(0, 5), color='red' - ) - self.score_label2 = toga.Label( - f'Team2: {self.score_team2}', margin=(0, 5), color='blue' - ) - self.separator_label = toga.Label(' - ', margin=(0, 10)) - - score_box = toga.Box(direction=ROW, margin=5) - score_box.add(self.score_label1) - score_box.add(self.separator_label) - score_box.add(self.score_label2) - - button_clear = toga.Button( - 'Clear', on_press=self.cb_clear, margin=(20, 5, 5) - ) - button_team1 = toga.Button( - 'Team 1 (+1)', on_press=self.cb_score_team1, margin=(20, 5, 5) - ) - button_team1.style.background_color = 'red' - button_team2 = toga.Button( - 'Team 2 (+1)', on_press=self.cb_score_team2, margin=5 - ) - button_team2.style.background_color = 'blue' - - main_box.add(score_box) - main_box.add(button_team1) - main_box.add(button_team2) - main_box.add(button_clear) - - self.main_window = toga.MainWindow(title=self.formal_name) - self.main_window.content = main_box - self.main_window.show() - - def cb_clear(self, _widget): - """Clear on press callback""" - self.score_team1 = 0 - self.score_team2 = 0 - self.refresh() - - def cb_score_team1(self, _widget): - """Team1 on press callback""" - self.score_team1 += 1 - self.refresh() - - def cb_score_team2(self, _widget): - """Team 2 on press callback""" - self.score_team2 += 1 - self.refresh() - - def refresh(self): - """Refreshes the score labels""" - self.score_label1.text = f'Team1: {self.score_team1}' - self.score_label2.text = f'Team2: {self.score_team2}' - - -def main(): - """main entry point""" - return ScoreCounter() -- cgit v1.3