MCPcopy Index your code
hub / github.com/python/cpython / _substitute

Method _substitute

Lib/tkinter/__init__.py:1735–1809  ·  view source on GitHub ↗

Internal function.

(self, *args)

Source from the content-addressed store, hash-verified

1733 _subst_format_str = " ".join(_subst_format)
1734
1735 def _substitute(self, *args):
1736 """Internal function."""
1737 if len(args) != len(self._subst_format): return args
1738 getboolean = self.tk.getboolean
1739
1740 getint = self.tk.getint
1741 def getint_event(s):
1742 """Tk changed behavior in 8.4.2, returning "??" rather more often."""
1743 try:
1744 return getint(s)
1745 except (ValueError, TclError):
1746 return s
1747
1748 if any(isinstance(s, tuple) for s in args):
1749 args = [s[0] if isinstance(s, tuple) and len(s) == 1 else s
1750 for s in args]
1751 nsign, b, d, f, h, k, s, t, w, x, y, A, E, K, N, W, T, X, Y, D = args
1752 # Missing: (a, c, m, o, v, B, R)
1753 e = Event()
1754 # serial field: valid for all events
1755 # number of button: ButtonPress and ButtonRelease events only
1756 # detail: for Enter, Leave, FocusIn, FocusOut and ConfigureRequest
1757 # events certain fixed strings (see Tcl/Tk documentation)
1758 # user_data: data string from a virtual event or an empty string
1759 # height field: Configure, ConfigureRequest, Create,
1760 # ResizeRequest, and Expose events only
1761 # keycode field: KeyPress and KeyRelease events only
1762 # time field: "valid for events that contain a time field"
1763 # width field: Configure, ConfigureRequest, Create, ResizeRequest,
1764 # and Expose events only
1765 # x field: "valid for events that contain an x field"
1766 # y field: "valid for events that contain a y field"
1767 # keysym as decimal: KeyPress and KeyRelease events only
1768 # x_root, y_root fields: ButtonPress, ButtonRelease, KeyPress,
1769 # KeyRelease, and Motion events
1770 e.serial = getint(nsign)
1771 e.num = getint_event(b)
1772 if T == EventType.VirtualEvent:
1773 e.user_data = d
1774 e.detail = '??'
1775 else:
1776 e.user_data = '??'
1777 e.detail = d
1778 try: e.focus = getboolean(f)
1779 except TclError: pass
1780 e.height = getint_event(h)
1781 e.keycode = getint_event(k)
1782 e.state = getint_event(s)
1783 e.time = getint_event(t)
1784 e.width = getint_event(w)
1785 e.x = getint_event(x)
1786 e.y = getint_event(y)
1787 e.char = A
1788 try: e.send_event = getboolean(E)
1789 except TclError: pass
1790 e.keysym = K
1791 e.keysym_num = getint_event(N)
1792 try:

Callers

nothing calls this directly

Calls 5

getbooleanFunction · 0.85
EventTypeClass · 0.85
strFunction · 0.85
EventClass · 0.70
anyFunction · 0.50

Tested by

no test coverage detected