Posted to tcl by kevin_walzer at Wed May 25 13:26:50 GMT 2011view raw

  1. pack [text .t]
  2.  
  3. .t tag config URL -underline 1
  4.  
  5. .t tag bind URL <Enter> [list .t configure -cursor hand2]
  6. .t tag bind URL <Leave> [list .t configure -cursor left_ptr]
  7.  
  8. set test {the text is http://wiki.tcl.tk}
  9.  
  10. foreach item $test {
  11. if {[regexp {(http|https|sftp|ftp|file)://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?} $test->url]} {
  12.  
  13. lappend tag URL
  14. .t insert end $item $tag
  15. } else {
  16. .t insert end $item
  17. }
  18. .t insert end \n
  19. }