【发布时间】:2021-04-01 01:20:26
【问题描述】:
在此代码中,当用户输入链接时,会显示链接的简短版本,但它不允许用户从 GUI 复制链接。我该如何解决这个问题?
import pyshorteners as pr
from tkinter import *
root = Tk()
e = Entry(root, width=50)
e.pack()
def click():
link = e.get()
shortener = pr.Shortener()
Short_Link = shortener.tinyurl.short(link)
Label1 = Label(root, text=Short_Link)
Label1.pack()
Button1 = Button(root, text="Enter link:", command=click)
Button1.pack()
root.mainloop()
【问题讨论】:
-
你可以使用一些按钮来复制文本,或者自动复制它,或者你可以
bind键Ctrl+C到窗口。或者您可以将其显示在Entry,然后您可以选择文本并使用Ctrl+C
标签: python python-3.x url tkinter