在python的tkinter中,如何制作标签,以便可以用鼠标选择文本?

在python的tkinter中,如何制作标签,以便可以用鼠标选择文本?,第1张

在python的tkinter中,如何制作标签,以便可以用鼠标选择文本

最简单的方法是使用高度为1行的禁用的文本小部件

from Tkinter import *master = Tk()w = Text(master, height=1, borderwidth=0)w.insert(1.0, "Hello, world!")w.pack()w.configure(state="disabled")# if tkinter is 8.5 or above you'll want the selection background# to appear like it does when the widget is activated# comment this out for older versions of Tkinterw.configure(inactiveselectbackground=w.cget("selectbackground"))mainloop()

您可以以类似方式使用条目窗口小部件。



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5663736.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存