First things first, Im german (strings in german aswell) and a bloody beginner when it comes to coding, but its fun and I want to improve.
Im currently working on a Youtube downloader GUI using python and tkinter. The cget attribute has worked in the past but I must have changed some little details that made this error occure.
Heres the code:
from tkinter import *
from tkinter import filedialog
from tkinter import font
from moviepy import *
from moviepy.video.io.VideoFileClip import VideoFileClip
from pytube import YouTube
from tkinter import *
from tkinter.ttk import *
import shutil
# functions
def select_path():
path = filedialog.askdirectory()
path_text.config(text=path)
def download_video():
get_link = url_entry.get()
user_path = path_text.cget("text")
screen.title("Lädt herunter...")
mp4_video= YouTube(get_link).streams.get_highest_resolution().download()
clip = VideoFileClip(mp4_video)
clip.close()
shutil.move(mp4_video, user_path)
screen.title("Download abgeschlossen!")
# head
screen = Tk()
icon = screen.iconbitmap(r'c:\Users\feera\OneDrive\Desktop\Codes\p3\et_logo.ico')
title = screen.title("EvilTube Downloader")
fonts = list(font.families())
fonts.sort()
screen.resizable(False, False)
# create canvas
canvas = Canvas(screen, width=500, height=500, bd=0, highlightthickness=0, relief='ridge')
canvas.pack(fill="both", expand=True)
# bg image
og_bg_img = PhotoImage(file=r"C:/Users/feera/OneDrive/Desktop/Codes/p3/images/bg_texture.png")
# bg position
dp_bg_img = og_bg_img.subsample(1,1)
canvas.create_image(0, 0, anchor=NW, image=dp_bg_img)
# ETD Logo
ETD_logo_img = PhotoImage(file=r"C:/Users/feera/OneDrive/Desktop/Codes/p3/images/et_full_logo.png")
# ETD Logo position
logo_img = ETD_logo_img.subsample(5,5)
canvas.create_image(250, 120, image=logo_img)
# flames
og_flames_img = PhotoImage(file=r"C:/Users/feera/OneDrive/Desktop/Codes/p3/images/flames.png")
# flames position
dp_flames_img = og_flames_img.subsample(3,3)
canvas.create_image(0, 280, anchor=NW, image=dp_flames_img)
# url input
url_entry = Entry(screen, width=60)
# add url input
canvas.create_text(250, 240, text="URL einfügen: ", font=("Agency FB", 17), fill="white")
canvas.create_window(250, 280, window=url_entry)
# select filepath
select_path_button = Button(screen, text="Speicherort auswählen", command=select_path)
# add select filepath
path_text = canvas.create_text(250, 330, text="Wähle einen Speicherort", font=("Agency FB", 16), fill="white")
canvas.create_window(250, 375, window=select_path_button)
# download button
download_button = Button(screen, text="Video herunterladen", command=download_video)
# add download button
canvas.create_window(250, 430, window=download_button)
screen.mainloop()
Ive already tried changing the name of some variables like the "path_text" variable. Im permanently looking for solutions on YT or other coding forums but im clueless what to do as I just started coding.