如何在 Python IDLE 中使用 ColorDelegator?

How does one use ColorDelegator in from Python IDLE?

我一直在为 Python 开发一个 IDE,我一直想知道如何通过集成 IDLE 的 colorDelegator 模块来节省自己很多时间。

是否可以使用它,我将如何使用它? (使用 tkinter 文本小部件)。

这是 ColorDelegator.py 底部的示例:

def main():
    from idlelib.Percolator import Percolator
    root = Tk()
    root.wm_protocol("WM_DELETE_WINDOW", root.quit)
    text = Text(background="white")
    text.pack(expand=1, fill="both")
    text.focus_set()
    p = Percolator(text)
    d = ColorDelegator()
    p.insertfilter(d)
    root.mainloop()