From 9e67bc6115d71485a5658703afba06a1cf12f354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Mendon=C3=A7a=20Ferreira?= Date: Fri, 2 Nov 2018 16:53:52 -0300 Subject: [PATCH] Allow Image update to set size Previously, updating an Image element with a new size would change the element size, possibly disrupting the GUI layout. Sometimes using a specified / fixed image size is preferred. This patch allows an optional size argument to the Update method. --- PySimpleGUI.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 193d7d44..2e83ca23 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1518,7 +1518,7 @@ class Image(Element): tooltip=tooltip) return - def Update(self, filename=None, data=None): + def Update(self, filename=None, data=None, size=(None,None)): if filename is not None: image = tk.PhotoImage(file=filename) elif data is not None: @@ -1531,9 +1531,8 @@ class Image(Element): # image = data else: return - width, height = image.width(), image.height() + width, height = size[0] or image.width(), size[1] or image.height() self.tktext_label.configure(image=image, width=width, height=height) - # self.tktext_label.configure(image=image) self.tktext_label.image = image def __del__(self):