blob: be66dc89b4cae8f2ff5d0d04b1206d04caa26d25 [file] [log] [blame]
Guido van Rossumf06ee5f1996-11-27 19:52:01 +00001#! /usr/bin/env python
Guido van Rossumdfa70a91995-01-10 17:05:37 +00002
3# www7.py -- display the contents of a URL in a Text widget
4# - set window title
5# - make window resizable
6# - update display while reading
7
8import sys
9import urllib
10from Tkinter import *
11
12def main():
13 if len(sys.argv) != 2 or sys.argv[1][:1] == '-':
14 print "Usage:", sys.argv[0], "url"
15 sys.exit(2)
16 url = sys.argv[1]
17 fp = urllib.urlopen(url)
18
19 root = Tk()
20 root.title(url)
21 root.minsize(1, 1)
22 text = Text(root)
23 text.pack({'expand': 1, 'fill': 'both'})
24
25 while 1:
26 line = fp.readline()
27 if not line: break
28 text.insert('end', line)
29 root.update_idletasks() # Update display
30
31 root.mainloop()
32
33main()