class
Tube(wx.Frame):
def __init__(self, *args,
**kwargs):
super(Tube, self, *args,
**kwargs).__init__(parent=None,id=wx.ID_ANY, title="New Frame", size=(600, 400))
self.Centre()
self.panel = wx.Panel(self, id=wx.ID_ANY, name="New Panel")
self.textLink = wx.StaticText(parent=self.panel, id=wx.ID_ANY, label="Edit YouTube URL", pos=(100, 50))
self.editLink = wx.TextCtrl(parent=self.panel, id=wx.ID_ANY, size=(200, 25), pos=(250,50))
self.downloadButton = wx.Button(parent=self.panel, id=wx.ID_ANY, label="Download Video", pos=(250, 100))
self.downloadButton.Bind(event=wx.EVT_BUTTON, handler=self.thread, source=self.downloadButton)
self.progress = wx.Gauge(parent=self.panel, id=wx.ID_ANY, range=100,size=(200,25), pos=(200, 200))
self.Show()
def progressBar(self, *args,
**kwargs):
for value in range(101):
wx.CallAfter(self.progress.SetValue, value)
sleep(0.2)
def Download(self, *args,
**kwargs):
self.video = YouTube(self.editLink.GetValue())
self.stream = self.video.streams.get_lowest_resolution()
self.stream.download()
def thread(self, *args,
**kwargs):
self.threads = []
self.thread1 = Thread(target=self.Download)
self.thread2 = Thread(target=self.progressBar)
self.threads.append(self.thread1)
self.threads.append(self.thread2)
for thread in self.threads:
thread.setDaemon(True)
thread.start()
if __name__ == '__main__':
app = wx.App()
screen = Tube()
app.MainLoop()