Ive been working on a simple youtube downloader as a project to build up some practice with the Tkinter module. The issue i'm running into is that i'm not quite sure how to output the content of the console into a text box widget as well as handling the download function running on a separate thread simultaneously.
Here is an example of what I how I want it to output:
![[Image: convert.png]](https://i.ibb.co/R7BRXwz/convert.png)
Here is my code:
(I know its clunky with a ton of unnecessary imports)
Any help would be heavily appreciated.
Here is an example of what I how I want it to output:
![[Image: convert.png]](https://i.ibb.co/R7BRXwz/convert.png)
Here is my code:
(I know its clunky with a ton of unnecessary imports)
PHP Code
<?php
from __future__ import unicode_literals
import tkinter
from tkinter import *
import os
import sys
from shutil import copytree, ignore_patterns
import youtube_dl
import os.path
from os import path
import ctypes
import time
import threading
def redirector(inputStr):
text_out.insert(INSERT, inputStr)
def convert(url_list):
#youtube options for each downloaded video
ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
}
#Converts a list of youtube URLs
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(url_list)
def get_text():
content = body.get(1.0, "end-1c")
content_list = content.split('\n')
content_list_ref = []
for url in content_list:
content_list_ref.append(url.strip(' '))
if len(content_list_ref) < 2:
print("No Video URL Entered")
else:
t1 = threading.Thread(target=convert, args=(content_list_ref,))
t1.start()
t1.join()
#main window
master = tkinter.Tk()
master.geometry("700x480")
master.title("Simple Youtube Downloader")
master.resizable(False, False)
#URL text box
body = tkinter.Text(master, height=16, width=50, borderwidth=3)
body.place(x=10, y=10)
#Large YouTube icon
canvas = Canvas(master, width = 300, height = 300)
canvas.place(x=420, y=-50)
img = PhotoImage(file='YoutubeDownloader\icon.png')
canvas.create_image(20,20, anchor=NW, image=img)
#Download Button
button = tkinter.Button(master, text="Download", width=20, height=2, command=lambda:[get_text()])
button.place(x=490, y=350)
#Dev credit
label = Label(master, text="")
label.place(x=525, y=450)
#Bottom console window
text_out = Text(master, height=10, width=50)
text_out.place(x=11, y= 300)
master.mainloop()
Any help would be heavily appreciated.

