如何使Tk标签中的文本可选? [英] How to make the text in a Tk label selectable?

查看:107
本文介绍了如何使Tk标签中的文本可选?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Tcl Tk中创建标签,但是无法选择它们的文本(用于复制粘贴).我该如何选择呢?

I'm creating labels in Tcl Tk, but their text is not selectable (for copy-paste). How do I make is selectable?

我使用以下方法包装标签:

I crate the labels using:

set n 0
foreach t $list_of_labels {
    incrr n
    set lbl2 [label .prop_menu.main_frame.val_$n    -text $t]
    grid $lbl2 ...
}

推荐答案

我通过使用只读条目来解决它,我将标签的创建替换为:

I solved it by using read only entries, I replaced the creation of the label with:

set lbl2 [entry .prop_menu.main_frame.val_$n -relief flat]
$lbl2 insert 0 $t
$lbl2 configure -state readonly

并且能够创建类似于标签但可以选择的条目.

And was able to create entries that act like labels but are selectable.

这篇关于如何使Tk标签中的文本可选?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆