Clarify portability and main program.
[python/dscho.git] / Demo / tkinter / www / www5.py
blob83f6ab9b6a7c65aa0510232124dc8a5878e17714
1 #! /usr/bin/env python
3 # www5.py -- display the contents of a URL in a Text widget
4 # - set window title
6 import sys
7 import urllib
8 from Tkinter import *
10 def 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)
17 root = Tk()
18 root.title(url) # Set window manager title
19 text = Text(root)
20 text.pack()
22 while 1:
23 line = fp.readline()
24 if not line: break
25 text.insert('end', line)
27 text.mainloop()
29 main()