mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Initial revision
This commit is contained in:
parent
df79a1ee19
commit
c636014c43
47 changed files with 5492 additions and 0 deletions
31
Lib/lib-stdwin/filewin.py
Normal file
31
Lib/lib-stdwin/filewin.py
Normal file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue