Return OriginalCommand(operation) after registering function. Registration adds an operation: function pair to ._operations. It also adds a widget function attribute that masks the tkinter class instance method. Method masking operates independently from command dis
(self, operation, function)
| 64 | # if instance is deleted after close, as in Percolator. |
| 65 | |
| 66 | def register(self, operation, function): |
| 67 | '''Return OriginalCommand(operation) after registering function. |
| 68 | |
| 69 | Registration adds an operation: function pair to ._operations. |
| 70 | It also adds a widget function attribute that masks the tkinter |
| 71 | class instance method. Method masking operates independently |
| 72 | from command dispatch. |
| 73 | |
| 74 | If a second function is registered for the same operation, the |
| 75 | first function is replaced in both places. |
| 76 | ''' |
| 77 | self._operations[operation] = function |
| 78 | setattr(self.widget, operation, function) |
| 79 | return OriginalCommand(self, operation) |
| 80 | |
| 81 | def unregister(self, operation): |
| 82 | '''Return the function for the operation, or None. |