3 # www8.py -- display the contents of a URL in a Text widget
5 # - make window resizable
6 # - update display while reading
7 # - vertical scroll bar
14 if len(sys
.argv
) != 2 or sys
.argv
[1][:1] == '-':
15 print "Usage:", sys
.argv
[0], "url"
18 fp
= urllib
.urlopen(url
)
25 # The Scrollbar *must* be created first -- this is magic for me :-(
26 vbar
= Scrollbar(root
)
27 vbar
.pack({'fill': 'y', 'side': 'right'})
28 text
= Text(root
, {'yscrollcommand': (vbar
, 'set')})
29 text
.pack({'expand': 1, 'fill': 'both', 'side': 'left'})
31 # Link Text widget and Scrollbar -- this is magic for you :-)
32 ##text['yscrollcommand'] = (vbar, 'set')
33 vbar
['command'] = (text
, 'yview')
38 text
.insert('end', line
)
39 root
.update_idletasks()