嗨,我有个密码:
from tkinter import *
from tkinter import filedialog
from pytube import YouTube
class download_youtube_video:
def __init__(self):
self.ydownload4u = Tk()
self.ydownload4u.title("Youtube download for you")
self.ydownload4u.geometry("400x400+600+250")
label_title = Label(self.ydownload4u, text="Youtube Download For You", font="times 25 bold underline")
label_title.place(x=40, y=10)
label_link = Label(self.ydownload4u, text="Please enter link of video Youtube:", font="times 15")
label_link.place(x=35, y=70)
self.box_link = Entry(self.ydownload4u, width="35")
self.box_link.place(x=30, y=100)
label_save = Label(self.ydownload4u, text="Please select where save file:", font="times 15")
label_save.place(x=35, y=150)
self.save_location = Button(self.ydownload4u, text="save as", command=lambda :self.save_as())
self.save_location.place(x=260, y=135)
self.save_location.config(height = 3, width = 10)
self.label_show_loction = Label(self.ydownload4u, text="You are save file here: ")
self.label_show_loction.place(x=35, y=220)
self.label_show_loction1 = Label(self.ydownload4u, text= lambda :self.save_as())
self.label_show_loction1.place(x=175, y=220)
self.ydownload4u.mainloop()
def save_as(self):
self.save = filedialog.askdirectory()我想在self.label_show_loction1展示self.save的位置,我试着把self.save放在self.label_show_loction1里,他给我按摩: 140544723958912,请帮我
发布于 2020-07-01 22:55:03
只需从tk中创建一个字符串变量,并将其添加到您的标签、按钮或任何类型的组件中,如:
self.loc1 = tk.StringVar(value="")
self.label_show_loction1 = Label(self.ydownload4u, textvariable=self.loc1)要更改变量值,可以执行以下操作:
tk.Button(self.frameName, text="save as", command=self.save_as)
def save_as(self):
save = filedialog.askdirectory()
self.loc1.set(save)当您单击该按钮时,变量将被更新并显示在您放置的位置。
https://stackoverflow.com/questions/62686393
复制相似问题