13 from __future__
import absolute_import
14 from __future__
import print_function
30 def __init__(self, parent=None, rows=24, columns=80):
41 tk.Frame.__init__(self, self.
parent)
43 self.pack(expand=1, fill=tk.BOTH)
44 self.rowconfigure(0, weight=1)
45 self.columnconfigure(0, weight=1)
49 self.
text = tk.Text(self, height=rows, width=columns, wrap=tk.NONE, takefocus=0)
50 self.text.grid(row=0, column=0, sticky=tk.N+tk.E+tk.W+tk.S)
54 self.
vbar = tk.Scrollbar(self, orient=tk.VERTICAL, command=self.text.yview)
55 self.
text[
'yscrollcommand'] = self.vbar.set
58 self.
hbar = tk.Scrollbar(self, orient=tk.HORIZONTAL, command=self.text.xview)
59 self.
text[
'xscrollcommand'] = self.hbar.set
75 yv = self.text.yview()
76 if not self.
vbar_visible and (yv[0] != 0.0
or yv[1] != 1.0):
78 self.vbar.grid(row=0, column=1, sticky=tk.N+tk.S)
79 elif self.
vbar_visible and yv[0] == 0.0
and yv[1] == 1.0:
81 self.vbar.grid_forget()
85 xv = self.text.xview()
86 if not self.
hbar_visible and (xv[0] != 0.0
or xv[1] != 1.0):
88 self.hbar.grid(row=1, column=0, sticky=tk.E+tk.W)
89 elif self.
hbar_visible and xv[0] == 0.0
and xv[1] == 1.0:
91 self.hbar.grid_forget()
96 self.text.insert(pos, text)
129 raise IOError(
'File is not open for reading.')
131 raise IOError(
'File is not open for reading.')
133 raise IOError(
'File is not open for reading.')
135 raise IOError(
'File is not open for reading.')
137 raise IOError(
'File is not open for reading.')
139 raise IOError(
'File is not open for reading.')
144 return len(self.
text[
'text'])
149 self.
text[
'text'] = self.
text[
'text'][0:size]
151 self.text.yview_moveto(1.0)
157 self.text.yview_moveto(1.0)
161 self.text.yview_moveto(1.0)