def __init__(self, widget): self.dict = {} self.widget = widget self.tk = tk = widget.tk w = widget._w self.orig = w + "_orig" tk.call("rename", w, self.orig) tk.createcommand(w, self.dispatch)
def close(self): for name in self.dict.keys(): self.unregister(name) widget = self.widget; del self.widget orig = self.orig; del self.orig tk = widget.tk w = widget._w tk.deletecommand(w) tk.call("rename", orig, w)