I used thread to keep my UI alive while i download a video in the background
Here is the button that call the thread function
button = Button(root, text="submit", background='#856ff8', foreground='black', font=BOLD,
command=lambda:thread("video url from the internet"))
here is the thread function
def thread(url):
update_label.configure(text='downloading..')
thread = threading.Thread(target=downloadVideo, args=(url))
thread.start()
Here is the downloadVideo function
def downloadVideo(url):
try:
urllib.request.urlretrieve(url, 'last video you downloaded.mp4')
update_label.configure(text="download successfully!")
except:
update_label.configure(text="download failed!")
and i get this error
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Python39\lib\threading.py", line 954, in _bootstrap_inner
self.run()
File "C:\Python39\lib\threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
TypeError: downloadVideo() takes 1 positional argument but 133 were given