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

Method dispatch

Lib/idlelib/redirector.py:97–117  ·  view source on GitHub ↗

Callback from Tcl which runs when the widget is referenced. If an operation has been registered in self._operations, apply the associated function to the args passed into Tcl. Otherwise, pass the operation through to Tk via the original Tcl function. Note that if a

(self, operation, *args)

Source from the content-addressed store, hash-verified

95 return None
96
97 def dispatch(self, operation, *args):
98 '''Callback from Tcl which runs when the widget is referenced.
99
100 If an operation has been registered in self._operations, apply the
101 associated function to the args passed into Tcl. Otherwise, pass the
102 operation through to Tk via the original Tcl function.
103
104 Note that if a registered function is called, the operation is not
105 passed through to Tk. Apply the function returned by self.register()
106 to *args to accomplish that. For an example, see colorizer.py.
107
108 '''
109 operation = str(operation) # can be a Tcl_Obj
110 m = self._operations.get(operation)
111 try:
112 if m:
113 return m(*args)
114 else:
115 return self.tk.call((self.orig, operation) + args)
116 except TclError:
117 return ""
118
119
120class OriginalCommand:

Callers 6

test_dispatchMethod · 0.45
test_dispatch_bypassMethod · 0.45
test_dispatch_errorMethod · 0.45

Calls 4

strFunction · 0.85
mFunction · 0.50
getMethod · 0.45
callMethod · 0.45

Tested by 6

test_dispatchMethod · 0.36
test_dispatch_bypassMethod · 0.36
test_dispatch_errorMethod · 0.36