MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / _find_target

Method _find_target

PySimpleGUI/PySimpleGUI.py:4991–5027  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4989 _exit_mainloop(self.ParentForm, self)
4990
4991 def _find_target(self):
4992 target = self.Target
4993 target_element = None
4994
4995 if target[0] == ThisRow:
4996 target = [self.Position[0], target[1]]
4997 if target[1] < 0:
4998 target[1] = self.Position[1] + target[1]
4999 strvar = None
5000 should_submit_window = False
5001 if target == (None, None):
5002 strvar = self.TKStringVar
5003 else:
5004 # Need a try-block because if the target is not hashable, the "in" test will raise exception
5005 try:
5006 if target in self.ParentForm.AllKeysDict:
5007 target_element = self.ParentForm.AllKeysDict[target]
5008 except:
5009 pass
5010 # if target not found or the above try got exception, then keep looking....
5011 if target_element is None:
5012 if not isinstance(target, str):
5013 if target[0] < 0:
5014 target = [self.Position[0] + target[0], target[1]]
5015 target_element = self.ParentContainer._GetElementAtLocation(target)
5016 else:
5017 target_element = self.ParentForm.find_element(target)
5018 try:
5019 strvar = target_element.TKStringVar
5020 except:
5021 pass
5022 try:
5023 if target_element.ChangeSubmits:
5024 should_submit_window = True
5025 except:
5026 pass
5027 return target_element, strvar, should_submit_window
5028
5029 # ------- Button Callback ------- #
5030 def ButtonCallBack(self):

Callers 2

ButtonCallBackMethod · 0.95

Calls 2

find_elementMethod · 0.80
_GetElementAtLocationMethod · 0.45

Tested by

no test coverage detected