Im a using Tcl-Tk 8.6.4 and I am a begginner,I want to create hyperlinks in my texts。 我正在寻找一个程序,该程序可以在参数中包含一个网站的网址,该网址将在我的文本中以蓝色和下划线显示。当然,通过点击网址,它会打开网站。 我发现了下面的代码,但我不确定它会做我想要的。如何在tcl tk中创建超链接?
proc hyperlink { name args } {
if { "Underline-Font" ni [ font names ] } {
font create Underline-Font {*}[ font actual TkDefaultFont ]
font configure Underline-Font -underline true -size 12
}
if { [ dict exists $args -command ] } {
set command [ dict get $args -command ]
dict unset args -command
}
label $name {*}$args -foreground blue -font Underline-Font
if { [ info exists command ] } {
bind $name <Button-1> $command
}
return $name
}
任何人都可以帮到我吗?
更新2
我想要的东西是在我的窗口一样,要显示的文字超链接:
更多信息给出以下这些链接:
- https://ccrma.stanford.edu/~jos/NumericalInt/Lumped_vs_Distributed_Systems.html
- https://ccrma.stanford.edu/~jos/NumericalInt/NumericalInt_4up.pdf
在一个过程来读取文件我有标签,如HTML标签如
"<hypLink>" { gets $infile inln hyperlink .hl${counter} -command [list eval exec [auto_execok start] "$inln"] -text "$inln" pack .hl${counter} incr counter }
在我的文件我写
半导体:
<hypLink> https://en.wikipedia.org/wiki/Semiconductor <hypLink> http://electronics.howstuffworks.com/diode.htm
我该怎么做才能拥有我想要的东西?
注意第一次更新已delated版权保护
让我知道如果编辑是否正确 – Jerry