R
R
Ruben Harutyunov2014-01-16 19:27:56
Python
Ruben Harutyunov, 2014-01-16 19:27:56

tkinter. How to abort file upload in urllib on GUI close?

There is the following code:

# -*- coding: utf-8 -*-
from Tkinter import *
import urllib,  ttk, tkMessageBox
from threading import Thread
def downloader():
    urllib.urlretrieve('http://cs521111v4.vk.me/u176613573/audios/e168af8959c0.mp3', 'file.mp3')
th=Thread(target=downloader,args=())
def starter(event):
    th.start()
    pb.pack()
    pb.start()

root= Tk()
pb = ttk.Progressbar(length = 200, orient = 'horizontal', mode = 'indeterminate')
but = Button(root, text = 'Go!')
root.minsize(width = 400, height = 350)
but.bind('<Button-1>', starter)
but.pack()
root.mainloop()

When the program window is closed, the file download continues. How to cancel a download?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
KPEBETKA, 2014-01-16
@K_DOT

Before th.start() add
Should help

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question