from idlelib.WidgetRedirector import WidgetRedirector
from idlelib.Delegator import Delegator
def __init__(self, text):
# XXX would be nice to inherit from Delegator
self.redir = WidgetRedirector(text)
self.top = self.bottom = Delegator(text)
self.bottom.insert = self.redir.register("insert", self.insert)
self.bottom.delete = self.redir.register("delete", self.delete)
while self.top is not self.bottom:
self.removefilter(self.top)
self.bottom.setdelegate(None); self.bottom = None
self.redir.close(); self.redir = None
def insert(self, index, chars, tags=None):
# Could go away if inheriting from Delegator
self.top.insert(index, chars, tags)
def delete(self, index1, index2=None):
# Could go away if inheriting from Delegator
self.top.delete(index1, index2)
def insertfilter(self, filter):
# Perhaps rename to pushfilter()?
assert isinstance(filter, Delegator)
assert filter.delegate is None
filter.setdelegate(self.top)
def removefilter(self, filter):
# XXX Perhaps should only support popfilter()?
assert isinstance(filter, Delegator)
assert filter.delegate is not None
self.top = filter.delegate
while f.delegate is not filter:
assert f is not self.bottom
f.setdelegate(filter.delegate)
def __init__(self, name):
Delegator.__init__(self, None)
print self.name, ": insert", args
self.delegate.insert(*args)
print self.name, ": delete", args
self.delegate.delete(*args)
root.title("Test Percolator")
width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
root.geometry("+%d+%d"%(x, y + 150))
cb1 = tk.Checkbutton(root, text="Tracer1", command=toggle1, variable=var1)
cb2 = tk.Checkbutton(root, text="Tracer2", command=toggle2, variable=var2)
if __name__ == "__main__":
from idlelib.idle_test.htest import run