blob: 83f6ab9b6a7c65aa0510232124dc8a5878e17714 [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# www5.py -- display the contents of a URL in a Text widget
4# - set window title
5
6import sys
7import urllib
8from Tkinter import *
9
10def main():
11 if len(sys.argv) != 2 or sys.argv[1][:1] == '-':
12 print "Usage:", sys.argv[0], "url"
13 sys.exit(2)
14 url = sys.argv[1]
15 fp = urllib.urlopen(url)
16
17 root = Tk()
18 root.title(url) # Set window manager title
19 text = Text(root)
20 text.pack()
21
22 while 1:
23 line = fp.readline()
24 if not line: break
25 text.insert('end', line)
26
27 text.mainloop()
28
29main()