From dcbbf319ebddd24e6bfd77b66b08697abb85467a Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 23 Aug 2018 12:45:51 -0400 Subject: [PATCH] Update method for Text Element now includes colors --- PySimpleGUI.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 51ac0bfc..78430d43 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -482,10 +482,15 @@ class Text(Element): super().__init__(ELEM_TYPE_TEXT, scale, size, auto_size_text, background_color=bg, font=font if font else DEFAULT_FONT, text_color=self.TextColor) return - def Update(self, NewValue): - self.DisplayText=NewValue - stringvar = self.TKStringVar - stringvar.set(NewValue) + def Update(self, new_value = None, background_color=None, text_color=None): + if new_value is not None: + self.DisplayText=new_value + stringvar = self.TKStringVar + stringvar.set(new_value) + if background_color is not None: + self.TKText.configure(background=background_color) + if text_color is not None: + self.TKText.configure(fg=text_color) def __del__(self): super().__del__() @@ -1478,6 +1483,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form): if element.TextColor != COLOR_SYSTEM_DEFAULT and element.TextColor is not None: tktext_label.configure(fg=element.TextColor) tktext_label.pack(side=tk.LEFT) + element.TKText = tktext_label # print(f'Text element placed w = {width}, h = {height}, wrap = {wraplen}') # ------------------------- BUTTON element ------------------------- # elif element_type == ELEM_TYPE_BUTTON: