From 18cf64ff465efbef39ec38bb760ec35b2fe26637 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Mon, 10 Apr 2023 19:10:13 +0200 Subject: add season selection to menu bar --- gui/main_window.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/gui/main_window.py b/gui/main_window.py index 7247e8e..9e2f40e 100644 --- a/gui/main_window.py +++ b/gui/main_window.py @@ -11,6 +11,7 @@ class MainWindow(QMainWindow): cursor: mariadb.Cursor = None db: mariadb.Connection = None menu_bar: QMenuBar + calendar_id: int _tab_drivers: TabDrivers _tab_teams: TabTeams @@ -47,6 +48,17 @@ class MainWindow(QMainWindow): def call_delete_flags(self): self.cursor.execute("call spDeleteFlags()") + def update(self, cascade=True): + if cascade == False: return + self._tab_drivers.update() + self._tab_teams.update() + # self._tab_circuits.update() + # self._tab_races.update() + + def switch_season(self): + self.calendar_id = self.sender().property("id") + self.update() + def __init__(self, cursor: mariadb.Cursor, db: mariadb.Connection, parent=None): super(MainWindow, self).__init__(parent) @@ -85,8 +97,19 @@ class MainWindow(QMainWindow): action.triggered.connect(self.commit) menu = self.menu_bar.addMenu("seasons") + group = QActionGroup(menu) + group.setExclusive(True) + self.cursor.execute("select ID, year from calendar") + for i, season in enumerate(self.cursor.fetchall()): + action = menu.addAction(str(season[1])) + action.setProperty("id", season[0]) + action.triggered.connect(self.switch_season) + action.setCheckable(True) + if i == 0: + action.setChecked(True) + self.calendar_id = season[0] + group.addAction(action) self.setMenuBar(self.menu_bar) self.setCentralWidget(main_layout) - -- cgit v1.2.3