[Tutor] (no subject)

Glen Bunting Glen@ihello-inc.com
Tue, 10 Apr 2001 15:27:09 -0700


Below is a simple script I wrote to download a file, time how long it takes
to download and display the bandwidth usage in Tkinter.  It works initially.
But the while loop does not work.  After the initial run, the program just
hangs there and I cannot even exit out of the Tkinter that pops up.  What am
I doing wrong?

Thanks

#!/usr/bin/env python

import os, urllib, time, Tkinter
from Tkinter import *

while 1:
    urllib.urlopen('http://www.esynch.com')
    first = time.time()
    urllib.urlretrieve('http://www.esynch.com/mw_test.dat', 'test')
    second = time.time()
    speed1 = second - first
    print speed1
    speed = round(speed1, 1)
    
    top = Tkinter.Tk()

    label = Tkinter.Label(top, text = 'Kilobytes/sec:')
    label.pack()

    bandwidth = Tkinter.Label(top, text = speed)
    bandwidth.pack()

    quit = Tkinter.Button(top, text = 'QUIT',
                      command=top.quit, bg='red', fg='white')
    quit.pack()
    Tkinter.mainloop()
    time.sleep(500)


Glen