0
0
mirror of https://github.com/python/cpython.git synced 2024-12-01 11:15:56 +01:00
cpython/Lib/stdwin/filewin.py
1990-10-13 19:23:40 +00:00

32 lines
551 B
Python
Executable File

# 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