MCPcopy Index your code
hub / github.com/RustPython/RustPython / _substitute

Method _substitute

Lib/tkinter/__init__.py:1717–1782  ·  view source on GitHub ↗

Internal function.

(self, *args)

Source from the content-addressed store, hash-verified

1715 _subst_format_str = " ".join(_subst_format)
1716
1717 def _substitute(self, *args):
1718 """Internal function."""
1719 if len(args) != len(self._subst_format): return args
1720 getboolean = self.tk.getboolean
1721
1722 getint = self.tk.getint
1723 def getint_event(s):
1724 """Tk changed behavior in 8.4.2, returning "??" rather more often."""
1725 try:
1726 return getint(s)
1727 except (ValueError, TclError):
1728 return s
1729
1730 if any(isinstance(s, tuple) for s in args):
1731 args = [s[0] if isinstance(s, tuple) and len(s) == 1 else s
1732 for s in args]
1733 nsign, b, f, h, k, s, t, w, x, y, A, E, K, N, W, T, X, Y, D = args
1734 # Missing: (a, c, d, m, o, v, B, R)
1735 e = Event()
1736 # serial field: valid for all events
1737 # number of button: ButtonPress and ButtonRelease events only
1738 # height field: Configure, ConfigureRequest, Create,
1739 # ResizeRequest, and Expose events only
1740 # keycode field: KeyPress and KeyRelease events only
1741 # time field: "valid for events that contain a time field"
1742 # width field: Configure, ConfigureRequest, Create, ResizeRequest,
1743 # and Expose events only
1744 # x field: "valid for events that contain an x field"
1745 # y field: "valid for events that contain a y field"
1746 # keysym as decimal: KeyPress and KeyRelease events only
1747 # x_root, y_root fields: ButtonPress, ButtonRelease, KeyPress,
1748 # KeyRelease, and Motion events
1749 e.serial = getint(nsign)
1750 e.num = getint_event(b)
1751 try: e.focus = getboolean(f)
1752 except TclError: pass
1753 e.height = getint_event(h)
1754 e.keycode = getint_event(k)
1755 e.state = getint_event(s)
1756 e.time = getint_event(t)
1757 e.width = getint_event(w)
1758 e.x = getint_event(x)
1759 e.y = getint_event(y)
1760 e.char = A
1761 try: e.send_event = getboolean(E)
1762 except TclError: pass
1763 e.keysym = K
1764 e.keysym_num = getint_event(N)
1765 try:
1766 e.type = EventType(T)
1767 except ValueError:
1768 try:
1769 e.type = EventType(str(T)) # can be int
1770 except ValueError:
1771 e.type = T
1772 try:
1773 e.widget = self._nametowidget(W)
1774 except KeyError:

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected