From 7383be254fc589f4a4d4dabc928dac3076ce74a2 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 21 Aug 2019 18:34:12 -0400 Subject: [PATCH] Ability to "call an element" --- PySimpleGUIWeb/PySimpleGUIWeb.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/PySimpleGUIWeb/PySimpleGUIWeb.py b/PySimpleGUIWeb/PySimpleGUIWeb.py index 791afc4c..0a2ab68a 100644 --- a/PySimpleGUIWeb/PySimpleGUIWeb.py +++ b/PySimpleGUIWeb/PySimpleGUIWeb.py @@ -501,6 +501,23 @@ class Element(): elif visible is True: del(widget.attributes['hidden']) + + def __call__(self, *args, **kwargs): + """ + Makes it possible to "call" an already existing element. When you do make the "call", it actually calls + the Update method for the element. + Example: If this text element was in yoiur layout: + sg.Text('foo', key='T') + Then you can call the Update method for that element by writing: + window.FindElement('T')('new text value') + + :param args: + :param kwargs: + :return: + """ + return self.Update(*args, **kwargs) + + def __del__(self): pass