Use py_resource module
[python/dscho.git] / Demo / tkinter / www / www4.py
blob4351004ca45f38c7f44c94e299e73d22cacf2679
1 #! /usr/local/bin/python
3 # www4.py -- display the contents of a URL in a Text widget
5 import sys
6 import urllib
7 from Tkinter import *
9 def 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)
16 text = Text() # Create text widget
17 text.pack() # Realize it
19 while 1:
20 line = fp.readline()
21 if not line: break
22 text.insert('end', line) # Append line to text widget
24 text.mainloop() # Start Tk main loop
26 main()