logo       

RE: text in a widget, text-widget @ 1146167556: msg#00036

Subject: RE: text in a widget, text-widget @ 1146167556
Not sure exactly what you are trying to do but it sounds like you want
word that is clicked on.

Quick and dirty way would be:

$scrolled->selectWord();
my $word = $scrolled->getSelected();

The above will only get a single word, so would be a challenge if you
have a link with multiple words.

Lame way:

create a separate tag for each word and bind that to a sub for that
particular word. These seems like
a lot of overhead and I would imagine Text widget would have better
feature you can leverage on.

Efficient way:

? I will leave that up to you ;) or someone else more Text widget savvy
then myself.

Like I mentioned before I had never tried the link thing, just gave it a
quick try yesterday as a
proof that it could be done. Maybe some one else on the list could
provide a better solution. You should
be able figure out where your cursor is and then determine from there. I
don't use Text widgets very often 
in my UI's, only occasionally to display output from child processes
that I am running via some IPC. 
So I have limited knowledge of the feature set of the Text widget. You
may want to check the documentation.

Regards,

Mike

 


-----Original Message-----
From: owner-ptk@xxxxxxxxxxxxxxxxxx [mailto:owner-ptk@xxxxxxxxxxxxxxxxxx]
On Behalf Of Johan Meskens CS3 jmcs3
Sent: Thursday, April 27, 2006 12:59 PM
To: ptk@xxxxxxxxxxxxxxxxxx
Subject: Re: text in a widget, text-widget @ 1146167556



 Intrah onat Diria .. Tue, 25 Apr 2006 13:55:44 -0700
  ,Van Nieuwenhuize, Mike wrote  "Noalim y": 


> 
> Johan,
> 
> Here this will give you an idea how to create a link in a text widget 
> as well as some other tags.
> 
> HTH
> 
> Mike
> 
> use strict;
> use Tk;
> use Tk::Dialog;
> 
> my $mainWindow = MainWindow->new(-title => "Test Tags");
> 
> my $sc_width  = 100;
> my $sc_height = 15;
> 
> my $scrolled =  $mainWindow->Scrolled(
>                                         "Text",
>                                         -scrollbars => 'se',
>                                         -background => 'white',
>                                         -wrap       => 'none',
>                                         -width      => $sc_width,
>                                         -height     => $sc_height,
> 
> 
>                                         )->pack(
>                                                     -fill   => 'both',
>                                                     -expand => '0',
> 
>                                                     );
> 
> #lets set up some color tags for text
> $scrolled->tagConfigure('BLUE',-foreground => 'blue'); 
> $scrolled->tagConfigure('LINK',-underline => 1); 
> $scrolled->tagConfigure('RED',-background => 'red'); 
> $scrolled->tagBind('LINK',"<Button-1>",sub { $scrolled->Dialog(-text 
> => "Hey you pushed the link")->Show()});


i have a textfield where i have multiple pieces of text tagged with
'LINK'



 $scrolled->tagBind('LINK',"<Button-1>",sub { print
$scrolled->GetTextTaggedWith( 'LINK' ) } );

thus the above line prints all LINK-tagged texts how do i get to the
text of the specific link i klik on ?

thanks for your help
kind regards
jmcs3

> 
> my $frame = $mainWindow->Frame( -relief => 'ridge',-borderwidth => 
> 3,);
> 
> my $exitB  = $frame->Button(
>                             -text    => 'EXIT',
>                             -width   => 5,
>                             -command => sub { exit 0},
> 
>                             )->pack(
>                                         -side   => 'left',
>                                         -anchor => 'n',
> 
>                                         );
> 
> $frame->pack(
>                 -expand => 1,
>                 -fill   => 'x',
> 
>                 );
> 
> 
> $scrolled->insert('end',"Here is a green text\n",['GREEN']); 
> $scrolled->insert('end',"Here is a blue link\n",['BLUE','LINK']); 
> $scrolled->insert('end',"Here is a blue text with red 
> background",['BLUE','RED']);
> 
> 
> MainLoop();
> 
> -----Original Message-----
> From: owner-ptk@xxxxxxxxxxxxxxxxxx 
> [mailto:owner-ptk@xxxxxxxxxxxxxxxxxx]
> On Behalf Of Johan Meskens CS3 jmcs3
> Sent: Tuesday, April 25, 2006 11:12 AM
> To: ptk@xxxxxxxxxxxxxxxxxx
> Subject: text in a widget, text-widget
> 
> 
> hello
> 
> 
> i have an application with a couple of text widgets but i would like 
> to add some functionalities that at first and second sight are not 
> directly supported by the plain text widget itself
>  - ?
> 
> for example i would like certain lines of text within the textwidget 
> to take  different background colors according to certain parameters
> 
> also i would like to be able to detect certain sentences or words that

> would become 'links' and by clicking them i would open up different 
> windows
> 
> any suggestions to solutions and widgets for the above problems ?
> 
>  - i probably could use the canvas for the color-thing .. as i write 
> this ..
> 
> kind regards
> jmcs3
> 
> 
> 
> 
> 
> 
> 
> 
> --------the following could be unreadable @ 1145988711   ::: 
> --a-=-t-g-i-
>  , Bottom:
>  , particular
>  , ||
>  , |2
>  , },
>  , oo,loent,uaha
>  , ::::::opthe
>  , lead
>  , |
>  , |---|
>  , _________________
>  ,
> 
> 
> 
> 
> -++**==--++**==--++**==--++**==--++**==--++**==--++**==
> This message was posted through the Stanford campus mailing list
server.
> If you wish to unsubscribe from this mailing list, send the message 
> body of "unsubscribe ptk" to majordomo@xxxxxxxxxxxxxxxxxx
> 
> -++**==--++**==--++**==--++**==--++**==--++**==--++**==
> This message was posted through the Stanford campus mailing list 
> server.  If you wish to unsubscribe from this mailing list, send the 
> message body of "unsubscribe ptk" to majordomo@xxxxxxxxxxxxxxxxxx







--------the following could be unreadable @ 1146167912   ::: 
?
 , >
 , =>
 , paars
 , doubling
 , ,
 ,
670670670670670670670670670670670670e670e670i670iaiiaii670670i2670ei670i
2670670e670fagi670670ga670670ib670PLETATOANITAPLEe
 , |
 , o::m
 , takened
 , t,
 , |
 , 




-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list server.
If you wish to unsubscribe from this mailing list, send the message body
of "unsubscribe ptk" to majordomo@xxxxxxxxxxxxxxxxxx

-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@xxxxxxxxxxxxxxxxxx



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe