:
, , .
import Tkinter as tk
class WrapText(tk.Text):
def __init__(self, master, wraplength=100, **kw):
tk.Text.__init__(self, master, **kw)
self.bind("<Any-Key>", self.check)
self.wraplength = wraplength-1
def check(self, event=None):
line, column = self.index(tk.INSERT).split('.')
if event and event.keysym in ["BackSpace","Return"]: pass
elif int(column) > self.wraplength:
self.insert("%s.%s" % (line,column),"\n")
def wrap_insert(self, index, text):
for char in text:
self.check()
self.insert(index, char)
if __name__ == "__main__":
root = tk.Tk()
text = WrapText(root, wraplength=4000)
sb = tk.Scrollbar(root, orient="horizontal", command=text.xview)
text.configure(xscrollcommand=sb.set)
text.configure(wrap=tk.NONE)
text.pack(fill="both", expand=True)
sb.pack(side="bottom", fill="x")
text.wrap_insert("end","a"*4095)
text.wrap_insert("end","\n")
text.wrap_insert("end","b"*4095)
text.wrap_insert("end","\n")
text.wrap_insert("end","c"*4095)
root.mainloop()
, -, ( ), -, , , , .