From ee81ce64fb7a3bc0063cdfa304714d2307e73ee9 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 16 Jan 2019 17:22:15 -0500 Subject: [PATCH] Button image_subsample paramter now works if no size is set --- PySimpleGUI.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 40cb5957..3ad8a3f8 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -4917,10 +4917,10 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form:Window): if element.ImageFilename: # if button has an image on it tkbutton.config(highlightthickness=0) photo = tk.PhotoImage(file=element.ImageFilename) + if element.ImageSubsample: + photo = photo.subsample(element.ImageSubsample) if element.ImageSize != (None, None): width, height = element.ImageSize - if element.ImageSubsample: - photo = photo.subsample(element.ImageSubsample) else: width, height = photo.width(), photo.height() tkbutton.config(image=photo, compound=tk.CENTER, width=width, height=height) @@ -4928,10 +4928,10 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form:Window): if element.ImageData: # if button has an image on it tkbutton.config(highlightthickness=0) photo = tk.PhotoImage(data=element.ImageData) + if element.ImageSubsample: + photo = photo.subsample(element.ImageSubsample) if element.ImageSize != (None, None): width, height = element.ImageSize - if element.ImageSubsample: - photo = photo.subsample(element.ImageSubsample) else: width, height = photo.width(), photo.height() tkbutton.config(image=photo, compound=tk.CENTER, width=width, height=height)