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

Function _FindElementWithFocusInSubForm

PySimpleGUI/PySimpleGUI.py:15161–15212  ·  view source on GitHub ↗

Searches through a "sub-form" (can be a window or container) for the current element with focus :param form: a Window, Column, Frame, or TabGroup (container elements) :type form: container elements :return: Element :rtype: Element | None

(form)

Source from the content-addressed store, hash-verified

15159
15160
15161def _FindElementWithFocusInSubForm(form):
15162 """
15163 Searches through a "sub-form" (can be a window or container) for the current element with focus
15164
15165 :param form: a Window, Column, Frame, or TabGroup (container elements)
15166 :type form: container elements
15167 :return: Element
15168 :rtype: Element | None
15169 """
15170 for row_num, row in enumerate(form.Rows):
15171 for col_num, element in enumerate(row):
15172 if element.Type == ELEM_TYPE_COLUMN:
15173 matching_elem = _FindElementWithFocusInSubForm(element)
15174 if matching_elem is not None:
15175 return matching_elem
15176 elif element.Type == ELEM_TYPE_FRAME:
15177 matching_elem = _FindElementWithFocusInSubForm(element)
15178 if matching_elem is not None:
15179 return matching_elem
15180 elif element.Type == ELEM_TYPE_TAB_GROUP:
15181 matching_elem = _FindElementWithFocusInSubForm(element)
15182 if matching_elem is not None:
15183 return matching_elem
15184 elif element.Type == ELEM_TYPE_TAB:
15185 matching_elem = _FindElementWithFocusInSubForm(element)
15186 if matching_elem is not None:
15187 return matching_elem
15188 elif element.Type == ELEM_TYPE_PANE:
15189 matching_elem = _FindElementWithFocusInSubForm(element)
15190 if matching_elem is not None:
15191 return matching_elem
15192 elif element.Type == ELEM_TYPE_INPUT_TEXT:
15193 if element.TKEntry is not None:
15194 if element.TKEntry is element.TKEntry.focus_get():
15195 return element
15196 elif element.Type == ELEM_TYPE_INPUT_MULTILINE:
15197 if element.TKText is not None:
15198 if element.TKText is element.TKText.focus_get():
15199 return element
15200 elif element.Type == ELEM_TYPE_BUTTON:
15201 if element.TKButton is not None:
15202 if element.TKButton is element.TKButton.focus_get():
15203 return element
15204 else: # The "Catch All" - if type isn't one of the above, try generic element.Widget
15205 try:
15206 if element.Widget is not None:
15207 if element.Widget is element.Widget.focus_get():
15208 return element
15209 except:
15210 return None
15211
15212 return None
15213
15214
15215def AddMenuItem(top_menu, sub_menu_info, element, is_sub_menu=False, skip=False, right_click_menu=False):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected