Public Member Functions | Public Attributes | List of all members
python.textwindow.TextWindow Class Reference
Inheritance diagram for python.textwindow.TextWindow:

Public Member Functions

def __init__ (self, parent=None, rows=24, columns=80)
 
def check_scroll (self, event=None)
 
def insert (self, pos, text)
 
def append (self, text)
 
def fileno (self)
 
def close (self)
 
def flush (self)
 
def isatty (self)
 
def __next__ (self)
 
def read (self, size=0)
 
def readline (self, size=0)
 
def readlines (self, size=0)
 
def readline (self, size=0)
 
def seek (self, offset, pos=0)
 
def tell (self)
 
def truncate (self, size=0)
 
def write (self, text)
 
def writelines (self, lines)
 

Public Attributes

 parent
 
 text
 
 vbar
 
 vbar_visible
 
 hbar
 
 hbar_visible
 

Detailed Description

Definition at line 26 of file textwindow.py.

Constructor & Destructor Documentation

def python.textwindow.TextWindow.__init__ (   self,
  parent = None,
  rows = 24,
  columns = 80 
)

Definition at line 30 of file textwindow.py.

30  def __init__(self, parent=None, rows=24, columns=80):
31 
32  # Parent window.
33 
34  if parent == None:
35  self.parent = tk.Toplevel()
36  else:
37  self.parent = parent
38 
39  # Register our outermost frame in the parent window.
40 
41  tk.Frame.__init__(self, self.parent)
42  if parent == None:
43  self.pack(expand=1, fill=tk.BOTH)
44  self.rowconfigure(0, weight=1)
45  self.columnconfigure(0, weight=1)
46 
47  # Add an empty text widget.
48 
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)
51 
52  # Make scroll bars, but don't grid them yet.
53 
54  self.vbar = tk.Scrollbar(self, orient=tk.VERTICAL, command=self.text.yview)
55  self.text['yscrollcommand'] = self.vbar.set
56  self.vbar_visible = 0
57 
58  self.hbar = tk.Scrollbar(self, orient=tk.HORIZONTAL, command=self.text.xview)
59  self.text['xscrollcommand'] = self.hbar.set
60  self.hbar_visible = 0
61 
62  self.check_scroll()
63 
64  # Set event bindings (check scrollbar visibility when window size
65  # changes).
66 
67  self.text.bind('<Configure>', self.check_scroll)
68 
def check_scroll(self, event=None)
Definition: textwindow.py:71
def __init__(self, parent=None, rows=24, columns=80)
Definition: textwindow.py:30

Member Function Documentation

def python.textwindow.TextWindow.__next__ (   self)

Definition at line 128 of file textwindow.py.

128  def __next__(self):
129  raise IOError('File is not open for reading.')
def python.textwindow.TextWindow.append (   self,
  text 
)

Definition at line 101 of file textwindow.py.

101  def append(self, text):
102  self.insert(tk.END, text)
103 
def insert(self, pos, text)
Definition: textwindow.py:95
def python.textwindow.TextWindow.check_scroll (   self,
  event = None 
)

Definition at line 71 of file textwindow.py.

71  def check_scroll(self, event=None):
72 
73  # Check vertical scroll bar.
74 
75  yv = self.text.yview()
76  if not self.vbar_visible and (yv[0] != 0.0 or yv[1] != 1.0):
77  self.vbar_visible = 1
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:
80  self.vbar_visible = 0
81  self.vbar.grid_forget()
82 
83  # Check horizontal scroll bar.
84 
85  xv = self.text.xview()
86  if not self.hbar_visible and (xv[0] != 0.0 or xv[1] != 1.0):
87  self.hbar_visible = 1
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:
90  self.hbar_visible = 0
91  self.hbar.grid_forget()
92 
def check_scroll(self, event=None)
Definition: textwindow.py:71
def python.textwindow.TextWindow.close (   self)

Definition at line 116 of file textwindow.py.

116  def close(self):
117  return
def python.textwindow.TextWindow.fileno (   self)

Definition at line 111 of file textwindow.py.

111  def fileno(self):
112  return 2
113 
def python.textwindow.TextWindow.flush (   self)

Definition at line 118 of file textwindow.py.

118  def flush(self):
119  return
120 
def python.textwindow.TextWindow.insert (   self,
  pos,
  text 
)

Definition at line 95 of file textwindow.py.

95  def insert(self, pos, text):
96  self.text.insert(pos, text)
97  self.check_scroll()
98 
def check_scroll(self, event=None)
Definition: textwindow.py:71
def insert(self, pos, text)
Definition: textwindow.py:95
def python.textwindow.TextWindow.isatty (   self)

Definition at line 123 of file textwindow.py.

123  def isatty(self):
124  return False
125 
def python.textwindow.TextWindow.read (   self,
  size = 0 
)

Definition at line 130 of file textwindow.py.

130  def read(self, size=0):
131  raise IOError('File is not open for reading.')
def read(self, size=0)
Definition: textwindow.py:130
def python.textwindow.TextWindow.readline (   self,
  size = 0 
)

Definition at line 132 of file textwindow.py.

132  def readline(self, size=0):
133  raise IOError('File is not open for reading.')
def readline(self, size=0)
Definition: textwindow.py:132
def python.textwindow.TextWindow.readline (   self,
  size = 0 
)

Definition at line 136 of file textwindow.py.

136  def readline(self, size=0):
137  raise IOError('File is not open for reading.')
def readline(self, size=0)
Definition: textwindow.py:132
def python.textwindow.TextWindow.readlines (   self,
  size = 0 
)

Definition at line 134 of file textwindow.py.

134  def readlines(self, size=0):
135  raise IOError('File is not open for reading.')
def readlines(self, size=0)
Definition: textwindow.py:134
def python.textwindow.TextWindow.seek (   self,
  offset,
  pos = 0 
)

Definition at line 138 of file textwindow.py.

138  def seek(self, offset, pos=0):
139  raise IOError('File is not open for reading.')
140 
def seek(self, offset, pos=0)
Definition: textwindow.py:138
def python.textwindow.TextWindow.tell (   self)

Definition at line 143 of file textwindow.py.

143  def tell(self):
144  return len(self.text['text'])
145 
def python.textwindow.TextWindow.truncate (   self,
  size = 0 
)

Definition at line 148 of file textwindow.py.

148  def truncate(self, size=0):
149  self.text['text'] = self.text['text'][0:size]
150  self.check_scroll()
151  self.text.yview_moveto(1.0) # Scroll to bottom
152 
def check_scroll(self, event=None)
Definition: textwindow.py:71
def truncate(self, size=0)
Definition: textwindow.py:148
def python.textwindow.TextWindow.write (   self,
  text 
)

Definition at line 155 of file textwindow.py.

155  def write(self, text):
156  self.append(text)
157  self.text.yview_moveto(1.0) # Scroll to bottom
def python.textwindow.TextWindow.writelines (   self,
  lines 
)

Definition at line 158 of file textwindow.py.

158  def writelines(self, lines):
159  for line in lines:
160  self.append(line)
161  self.text.yview_moveto(1.0) # Scroll to bottom
162 
def writelines(self, lines)
Definition: textwindow.py:158

Member Data Documentation

python.textwindow.TextWindow.hbar

Definition at line 58 of file textwindow.py.

python.textwindow.TextWindow.hbar_visible

Definition at line 60 of file textwindow.py.

python.textwindow.TextWindow.parent

Definition at line 35 of file textwindow.py.

python.textwindow.TextWindow.text

Definition at line 49 of file textwindow.py.

python.textwindow.TextWindow.vbar

Definition at line 54 of file textwindow.py.

python.textwindow.TextWindow.vbar_visible

Definition at line 56 of file textwindow.py.


The documentation for this class was generated from the following file: