Skip to content

Commit

Permalink
Fix scrolling on linux, load stats on tab change
Browse files Browse the repository at this point in the history
  • Loading branch information
jake158 committed Apr 5, 2024
1 parent c1e7057 commit 67ec6d8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pomodorodiscord/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class TabView(ctk.CTkTabview):
def __init__(self, master, **kwargs):
super().__init__(master, **kwargs)
super().__init__(master, **kwargs, command=self.on_tab_change)
self.add("Main")
self.add("Settings")
self.add("Stats")
Expand All @@ -20,6 +20,15 @@ def __init__(self, master, **kwargs):
self.stats_frame = StatsFrame(self.tab("Stats"))
self.stats_frame.pack(expand=True, fill='both')

# Fixing scrolling on Linux
# https://github.com/TomSchimansky/CustomTkinter/issues/1356
self.stats_frame.bind_all("<Button-4>", lambda e: [frame._parent_canvas.yview("scroll", -1, "units") for frame in (self.stats_frame, self.settings_frame)])
self.stats_frame.bind_all("<Button-5>", lambda e: [frame._parent_canvas.yview("scroll", 1, "units") for frame in (self.stats_frame, self.settings_frame)])

def on_tab_change(self):
if self.get() == "Stats":
self.stats_frame.load_stats()


class PomodoroApp(ctk.CTk):
WIDTH = 350
Expand Down

0 comments on commit 67ec6d8

Please sign in to comment.