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)
| 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 | |
| 120 | class OriginalCommand: |