MCPcopy Index your code
hub / github.com/python/cpython / mywrite

Method mywrite

Lib/idlelib/squeezer.py:245–273  ·  view source on GitHub ↗
(s, tags=(), write=editwin.write)

Source from the content-addressed store, hash-verified

243 # Replace the PyShell instance's write method with a wrapper,
244 # which inserts an ExpandingButton instead of a long text.
245 def mywrite(s, tags=(), write=editwin.write):
246 # Only auto-squeeze text which has just the "stdout" tag.
247 if tags != "stdout":
248 return write(s, tags)
249
250 # Only auto-squeeze text with at least the minimum
251 # configured number of lines.
252 auto_squeeze_min_lines = self.auto_squeeze_min_lines
253 # First, a very quick check to skip very short texts.
254 if len(s) < auto_squeeze_min_lines:
255 return write(s, tags)
256 # Now the full line-count check.
257 numoflines = self.count_lines(s)
258 if numoflines < auto_squeeze_min_lines:
259 return write(s, tags)
260
261 # Create an ExpandingButton instance.
262 expandingbutton = ExpandingButton(s, tags, numoflines, self)
263
264 # Insert the ExpandingButton into the Text widget.
265 text.mark_gravity("iomark", tk.RIGHT)
266 text.window_create("iomark", window=expandingbutton,
267 padx=3, pady=5)
268 text.see("iomark")
269 text.update()
270 text.mark_gravity("iomark", tk.LEFT)
271
272 # Add the ExpandingButton to the Squeezer's list.
273 self.expandingbuttons.append(expandingbutton)
274
275 editwin.write = mywrite
276

Callers

nothing calls this directly

Calls 8

count_linesMethod · 0.95
ExpandingButtonClass · 0.85
mark_gravityMethod · 0.80
window_createMethod · 0.80
writeFunction · 0.50
seeMethod · 0.45
updateMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected