【问题标题】:Programme(Youtube download videos)节目(Youtube下载影片)
【发布时间】:2020-07-13 13:11:35
【问题描述】:
from tkinter import *
from pytube import YouTube
root=Tk()
root.geometry("400x350")
root.title("Youtube video downloader application")
def download():
    try:
        myVar.set("Downloading...")
        root.update()
        Youtube(link.get()).streams.first().download()
        link.set("Video download successfully")
    except Expection as e:
        myVar.set("Mistake")
        root.update()
        link.set("Enter correct link")
        Label(root,text="Welcome to youtube\nDownloader Application",font="Consolas 15 bold").pack()
        myVar=StringVar()
        myVar.set("Enter the link below")
        Entry(root,textvariable=myVar,width=40).pack(pady=10)
        link=StringVar()
        Entry(root, textvariable=myVar, width=40).pack(pady=10)
        Button(root,text="Download video",command=download).pack()
        root.mainloop()

这是我的代码,但是这段代码不起作用(程序完成 0)(在此之前我安装了 tkinter,pytube。)。我不知道如何重新编写这段代码。

【问题讨论】:

  • 你在哪里调用你的download()函数?
  • @takendarkk 我相信倒数第二行
  • 那是设置一个事件监听器。它实际上并没有调用该函数。在调用函数之前,该代码甚至不会执行。

标签: python tkinter


【解决方案1】:

您需要在download 函数之外的全局级别调用root.mainloo()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-03
    • 1970-01-01
    • 1970-01-01
    • 2020-09-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多