Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

html for string

Status
Not open for further replies.

edwong

Programmer
Mar 26, 2003
30
US
hi,
I am outputing html links to my text widget.
For example, is there a way in tk that can actually let me click on the link and go to the yahoo webpage?
If yes, how?
thx
 
Heres how I'd do what you are asking.

This routine may be different if you arent running on UNIX but you should be able to get an idea.

frame .f
label .f.l -text &quot;bind .f.l <B1-ButtonRelease> { exec netscape [.f.l cget -text] }
pack .f
pack .f.l

The bind command above launches netscape to the address of the text of the label.

If you are looking more into having these links occur in the middle of a large block of text i suggest looking into &quot;tag bind&quot;, which is an option for text widgets.

I hope this helps some
 
Thx for the reply.

I have a follow up question then.

Right now, I got all the url from a c++ function and i direct them into a ListBox widget for output.

.f.list insert end &quot;Search results as follows:&quot;
.f.list insert end &quot;&quot;
bind .f.list <B1-ButtonRelease> { exec netscape [.f.list -cget -text] }

but it give error when i click the url. It saids something like bad option on cget.....

any idea??

thx
 
Thx for the reply.

I tried couple things, but it still doesn't work.


bind .f.list <B1-ButtonRelease> { exec netscape [.f.list
cget -text] }

bind .f.list <B1-ButtonRelease> { exec netscape [.f.list get 0 1000] }

but it give error when i click the url. It saids something like can't recongize text .....

any idea?? is it because of the listbox widget??

thx
 
ok use that same bind command only in order to capture the text from the listbox you need the following.

[.f.list curselection] this returns the index of the item selected in the listbox

so if you fit this into your bind like so:

bind .f.list <B1-ButtonRelease> { exec netscape [.f.list get [.f.list curselection]] }

give that a shot

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top