From dac1dbd0847524745c5b9c30199112957aaa8304 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 16 Jan 2019 16:27:30 -0500 Subject: [PATCH 1/3] Completed animated GIFs. Support for time_between_frames --- PySimpleGUI.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index e20c2379..6534ee45 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1846,6 +1846,7 @@ class Image(Element): self.AnimatedFrames = None self.CurrentFrameNumber = 0 self.TotalAnimatedFrames = 0 + self.LastFrameTime = 0 super().__init__(ELEM_TYPE_IMAGE, size=size, background_color=background_color, pad=pad, key=key, tooltip=tooltip, visible=visible) @@ -1870,7 +1871,7 @@ class Image(Element): elif visible is True: self.tktext_label.pack() - def UpdateAnimation(self, source, size=(None, None)): + def UpdateAnimation(self, source, size=(None, None), time_between_frames=0): if self.AnimatedFrames is None: self.AnimatedFrames = [] for i in range(1000): @@ -1887,8 +1888,20 @@ class Image(Element): if size != (None, None): self.AnimatedFrames[i].configure self.TotalAnimatedFrames += 1 + self.LastFrameTime = time.time() # show the frame - self.CurrentFrameNumber = self.CurrentFrameNumber + 1 if self.CurrentFrameNumber+1< self.TotalAnimatedFrames else 0 + + now = time.time() + + if time_between_frames: + if (now - self.LastFrameTime) * 1000 > time_between_frames: + self.LastFrameTime = now + self.CurrentFrameNumber = self.CurrentFrameNumber + 1 if self.CurrentFrameNumber+1< self.TotalAnimatedFrames else 0 + else: # don't reshow the frame again if not time for new frame + return + else: + self.CurrentFrameNumber = self.CurrentFrameNumber + 1 if self.CurrentFrameNumber+1< self.TotalAnimatedFrames else 0 + self.tktext_label.configure(image=self.AnimatedFrames[self.CurrentFrameNumber]) From 7a7fac519f361daa0fa3b9e14e1feecaeca0a752 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 16 Jan 2019 16:30:49 -0500 Subject: [PATCH 2/3] Fonts for tables. font parameter now works --- PySimpleGUI.py | 1 + 1 file changed, 1 insertion(+) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 6534ee45..69df59f3 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -5692,6 +5692,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form:Window): ttk.Style().configure("Treeview", foreground=element.TextColor) if element.RowHeight is not None: ttk.Style().configure("Treeview", rowheight=element.RowHeight) + ttk.Style().configure("Treeview", font=font) # scrollable_frame.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], expand=True, fill='both') treeview.bind("<>", element.treeview_selected) if element.BindReturnKey: From e0d3fb3f736f2ee630628f05760345cae63328f2 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 16 Jan 2019 16:37:29 -0500 Subject: [PATCH 3/3] Calendar chooser window now stays on top of other windows --- PySimpleGUI.py | 1 + 1 file changed, 1 insertion(+) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 69df59f3..9de4cd62 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1600,6 +1600,7 @@ class Button(Element): should_submit_window = False root = tk.Toplevel() root.title('Calendar Chooser') + root.wm_attributes("-topmost", 1) self.TKCal = TKCalendar(master=root, firstweekday=calendar.SUNDAY, target_element=target_element, close_when_chosen=self.CalendarCloseWhenChosen, default_date=self.DefaultDate_M_D_Y ) self.TKCal.pack(expand=1, fill='both') root.update()