blob: 4351004ca45f38c7f44c94e299e73d22cacf2679 [file] [log] [blame]
Guido van Rossumdfa70a91995-01-10 17:05:37 +00001#! /usr/local/bin/python
2
3# www4.py -- display the contents of a URL in a Text widget
4
5import sys
6import urllib
7from Tkinter import *
8
9def main():
10 if len(sys.argv) != 2 or sys.argv[1][:1] == '-':
11 print "Usage:", sys.argv[0], "url"
12 sys.exit(2)
13 url = sys.argv[1]
14 fp = urllib.urlopen(url)
15
16 text = Text() # Create text widget
17 text.pack() # Realize it
18
19 while 1:
20 line = fp.readline()
21 if not line: break
22 text.insert('end', line) # Append line to text widget
23
24 text.mainloop() # Start Tk main loop
25
26main()