首页 > 解决方案 > Python tkinter 应用程序在 0 错误时运行时没有响应?

问题描述

我是 python 新手,我正在尝试开发一个基本应用程序来使用 pytube API 通过 url 下载 YouTube 视频。不幸的是,我的 IDE (pycharm) 没有显示任何错误,并且我的程序崩溃并显示“无响应”消息。有人有什么想法吗?感谢所有帮助。

干杯:)

我试过删除 Pytube 函数我也试过重启 Pycharm 和项目我试过删除函数和我的代码的不同配置

在任何小部件功能之前,程序应该只在正确的 x+y 位置运行小部件。`

    import os
    import tkinter as tk
    from pytube import YouTube

     root = tk.Tk()
    root.title("YouTube converter")
    root.geometry('800x300')

root.iconbitmap(r'C:\\Users\\matthew.harris\\youtube_tool\\youtube_tool\\icon.ico')
    root.resizable(0, 0)
    root.tk_setPalette(background='light grey')

    save_location = 'C:\\Users\\', os.environ.get('USER'), '\\Desktop'
    link = input()
    yt = YouTube(link)

    mp4files = yt.filter('mp4')
    download_func = yt.get(mp4files[-1].extension, mp4files[-1].resolution)


def get_video():
    try:
        download_func.download(save_location)
    except download_func as error:
        print('Some error')
        print('task completed')


textEntry = tk.Entry(root, font=100, width=50, bg='white', command=get_video())
textEntry.pack(side=tk.TOP, padx=0, pady=40)

youtubeID = tk.Label(root, text='Youtube video url')
youtubeID.place(x=1, y=45)

Convert_Button = tk.Button(root, text='Convert', command=get_video()).place(x=700, y=40)

videoOption = tk.IntVar()
R1 = tk.Radiobutton(root, text='MP3', variable=videoOption, value='MP3').place(x=500, y=100)
R2 = tk.Radiobutton(root, text='Video', variable=videoOption, value='Video').place(x=200, y=100)

root.mainloop()
``

标签: pythontkinteryoutubepytube

解决方案


推荐阅读