All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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__
 
def check_scroll
 
def insert
 
def append
 
def fileno
 
def close
 
def flush
 
def isatty
 
def __next__
 
def read
 
def readline
 
def readlines
 
def readline
 
def seek
 
def tell
 
def truncate
 
def write
 
def writelines
 

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

Member Function Documentation

def python.textwindow.TextWindow.__next__ (   self)

Definition at line 128 of file textwindow.py.

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

Definition at line 101 of file textwindow.py.

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

Definition at line 71 of file textwindow.py.

71 
72  def check_scroll(self, event=None):
73 
74  # Check vertical scroll bar.
75 
76  yv = self.text.yview()
77  if not self.vbar_visible and (yv[0] != 0.0 or yv[1] != 1.0):
78  self.vbar_visible = 1
79  self.vbar.grid(row=0, column=1, sticky=tk.N+tk.S)
80  elif self.vbar_visible and yv[0] == 0.0 and yv[1] == 1.0:
81  self.vbar_visible = 0
82  self.vbar.grid_forget()
83 
84  # Check horizontal scroll bar.
85 
86  xv = self.text.xview()
87  if not self.hbar_visible and (xv[0] != 0.0 or xv[1] != 1.0):
88  self.hbar_visible = 1
89  self.hbar.grid(row=1, column=0, sticky=tk.E+tk.W)
90  elif self.hbar_visible and xv[0] == 0.0 and xv[1] == 1.0:
91  self.hbar_visible = 0
92  self.hbar.grid_forget()
def python.textwindow.TextWindow.close (   self)

Definition at line 116 of file textwindow.py.

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

Definition at line 111 of file textwindow.py.

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

Definition at line 118 of file textwindow.py.

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

Definition at line 95 of file textwindow.py.

95 
96  def insert(self, pos, text):
97  self.text.insert(pos, text)
98  self.check_scroll()
def python.textwindow.TextWindow.isatty (   self)

Definition at line 123 of file textwindow.py.

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

Definition at line 130 of file textwindow.py.

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

Definition at line 132 of file textwindow.py.

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

Definition at line 136 of file textwindow.py.

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

Definition at line 134 of file textwindow.py.

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

Definition at line 138 of file textwindow.py.

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

Definition at line 143 of file textwindow.py.

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

Definition at line 148 of file textwindow.py.

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

Definition at line 155 of file textwindow.py.

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

Definition at line 158 of file textwindow.py.

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

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: