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

Method block_focus

PySimpleGUI/PySimpleGUI.py:1532–1551  ·  view source on GitHub ↗

Enable or disable the element from getting focus by using the keyboard. If the block parameter is True, then this element will not be given focus by using the keyboard to go from one element to another. You CAN click on the element and utilize it. :param blo

(self, block=True)

Source from the content-addressed store, hash-verified

1530 _error_popup_with_traceback("Exception blocking focus. Check your element's Widget", e)
1531
1532 def block_focus(self, block=True):
1533 """
1534 Enable or disable the element from getting focus by using the keyboard.
1535 If the block parameter is True, then this element will not be given focus by using
1536 the keyboard to go from one element to another.
1537 You CAN click on the element and utilize it.
1538
1539 :param block: if True the element will not get focus via the keyboard
1540 :type block: bool
1541 """
1542 if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
1543 return
1544 try:
1545 self.ParentForm.TKroot.focus_force()
1546 if block:
1547 self.Widget.configure(takefocus=0)
1548 else:
1549 self.Widget.configure(takefocus=1)
1550 except Exception as e:
1551 _error_popup_with_traceback("Exception blocking focus. Check your element's Widget", e)
1552
1553 def get_next_focus(self):
1554 """

Callers

nothing calls this directly

Calls 2

_widget_was_createdMethod · 0.95

Tested by

no test coverage detected