idlelib.Percolator, idlelib.ColorDelegator

idlelib.Percolator, idlelib.ColorDelegator

わたしにきかないで

ちょいと作りたいものがあって、Pythonソース配布物の Demo を物色中。わかってやってるわけではないよ。

idlelib は確か

Python クックブック 第2版

新品価格
¥4,536から
(2015/2/19 02:45時点)


に載ってた記憶があるな、違ったか? (手許にないので確認出来ず。)

使用前

show_py.py
 1 # -*- coding: utf-8 -*-
 2 import Tkinter
 3 
 4 root = Tkinter.Tk()
 5 text_frame = Tkinter.Frame(root)
 6 text_frame.pack()
 7 text = Tkinter.Text(text_frame, name='text', padx=5,
 8                     wrap='word', width=80)
 9 text.pack()
10 #text.delete("1.0", "end")
11 text.insert("1.0", open("show_py.py", "r").read())
12 root.mainloop()

実行:

使用後

show_py.py
 1 # -*- coding: utf-8 -*-
 2 import Tkinter
 3 from idlelib.Percolator import Percolator
 4 from idlelib.ColorDelegator import ColorDelegator
 5 
 6 root = Tkinter.Tk()
 7 text_frame = Tkinter.Frame(root)
 8 text_frame.pack()
 9 text = Tkinter.Text(text_frame, name='text', padx=5,
10                     wrap='word', width=80)
11 text.pack()
12 Percolator(text).insertfilter(ColorDelegator())
13 #text.delete("1.0", "end")
14 text.insert("1.0", open("show_py.py", "r").read())
15 root.mainloop()

実行: