您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

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

在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 Tkinter
w.configure(inactiveselectbackground=w.cget("selectbackground"))

mainloop()

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

python 2022/1/1 18:43:50 有303人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶