Internal class. Stores function to call when some user defined Tcl function is called e.g. after an event occurred.
| 2051 | |
| 2052 | |
| 2053 | class CallWrapper: |
| 2054 | """Internal class. Stores function to call when some user |
| 2055 | defined Tcl function is called e.g. after an event occurred.""" |
| 2056 | |
| 2057 | def __init__(self, func, subst, widget): |
| 2058 | """Store FUNC, SUBST and WIDGET as members.""" |
| 2059 | self.func = func |
| 2060 | self.subst = subst |
| 2061 | self.widget = widget |
| 2062 | |
| 2063 | def __call__(self, *args): |
| 2064 | """Apply first function SUBST to arguments, than FUNC.""" |
| 2065 | try: |
| 2066 | if self.subst: |
| 2067 | args = self.subst(*args) |
| 2068 | return self.func(*args) |
| 2069 | except SystemExit: |
| 2070 | raise |
| 2071 | except: |
| 2072 | self.widget._report_exception() |
| 2073 | |
| 2074 | |
| 2075 | class XView: |