diff options
author | Guido van Rossum <guido@python.org> | 1990-10-13 19:23:40 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1990-10-13 19:23:40 (GMT) |
commit | c636014c430620325f8d213e9ba10d925991b8d7 (patch) | |
tree | 058a21f7da3d8c6e7da0756ef7b1402fe7169a1a /Lib/stdwin/filewin.py | |
parent | df79a1ee192231a75a381798bb35cefaf6c31a2a (diff) | |
download | cpython-c636014c430620325f8d213e9ba10d925991b8d7.zip cpython-c636014c430620325f8d213e9ba10d925991b8d7.tar.gz cpython-c636014c430620325f8d213e9ba10d925991b8d7.tar.bz2 |
Initial revision
Diffstat (limited to 'Lib/stdwin/filewin.py')
-rwxr-xr-x | Lib/stdwin/filewin.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/stdwin/filewin.py b/Lib/stdwin/filewin.py new file mode 100755 index 0000000..1beb0b6 --- /dev/null +++ b/Lib/stdwin/filewin.py @@ -0,0 +1,31 @@ +# Module 'filewin' +# File windows, a subclass of textwin (which is a subclass of gwin) + +import stdwin +import textwin +import path + +builtin_open = open + +def readfile(fn): # Return a string containing the file's contents + fp = builtin_open(fn, 'r') + a = '' + n = 8096 + while 1: + b = fp.read(n) + if not b: break + a = a + b + return a + + +# FILE WINDOW + +def open_readonly(fn): # Open a file window + w = textwin.open_readonly(fn, readfile(fn)) + w.fn = fn + return w + +def open(fn): # Open a file window + w = textwin.open(fn, readfile(fn)) + w.fn = fn + return w |