f



RE: text in a widget, text-widget @ 1146167556 #3

Johan,

Got to thinking about something that may work for you. Please see my
modified code.
Basically The only thing that I give it a is a list of words, the tag
and 
tag bind is generated on the fly. Maybe using an approach like this will
get
you closer to what you wanted. 

Still kinda lame as you have to create a new tag for each word or in
this case 
url but it at least will allow you to do it on the fly. 

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'); 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\n",['BLUE','RED']);

foreach my $string (qw/qualcomm ibm nokia tsmc microshoft gentoo
redhat/){

    my $url = "www.${string}.com";
    my $tag = create_link($string,$url);
    $scrolled->insert('end',"Click here to goto home page for
$string\n",['BLUE','LINK',$tag]);


}

MainLoop();

{

my $strings_hash = {};

sub create_link {

    my $string = shift;
    my $url    = shift;

    unless(exists $strings_hash->{$string}) {

        print "DEBUG: create link for $string\n";

        my $sub = sub { $scrolled->Dialog(-text => "Hey are you sure you
want to open page for $string which has the url $url")->Show() ;
openLink($string)};
        $scrolled->tagBind(uc($string),"<Button-1>",$sub); 

        $strings_hash->{$string} = $url;

    };#unless

    return uc($string);

}

sub openLink {

    my $string = shift;
    if(exists $strings_hash->{$string}) {
        $scrolled->Dialog(-text => "Warning: I can't open the url
$strings_hash->{$string}")->Show();
    }
    else { 
        $scrolled->Dialog(-text => "Error: I can't find the link for
$string")->Show();
    }

}

};#hide the hash


 

-----Original Message-----
From: owner-ptk@lists.stanford.edu [mailto:owner-ptk@lists.stanford.edu]
On Behalf Of Johan Meskens CS3 jmcs3
Sent: Thursday, April 27, 2006 12:59 PM
To: ptk@lists.stanford.edu
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@lists.stanford.edu 
> [mailto:owner-ptk@lists.stanford.edu]
> On Behalf Of Johan Meskens CS3 jmcs3
> Sent: Tuesday, April 25, 2006 11:12 AM
> To: ptk@lists.stanford.edu
> 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@lists.stanford.edu
> 
> -++**==--++**==--++**==--++**==--++**==--++**==--++**==
> 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@lists.stanford.edu







--------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@lists.stanford.edu

-++**==--++**==--++**==--++**==--++**==--++**==--++**==
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@lists.stanford.edu

0
Van
4/28/2006 5:17:46 PM
comp.lang.perl.tk 4721 articles. 0 followers. pharrendorf (19) is leader. Post Follow

0 Replies
859 Views

Similar Articles

[PageSpeed] 9

Reply:

Similar Artilces:

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( > ...

RE: text in a widget, text-widget @ 1146167556 #2
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 mor...

RE: text in a widget, text-widget
You can use tags with in the text widget. See the documentation in Tk::Text for more explanation on how they work. How to configure: $scrolled->tagConfigure('BLUE',-background => 'blue'); $scrolled->tagConfigure('RED',-foreground => 'red'); $scrolled->tagConfigure('GREEN',-foreground => 'green'); Here is how I use them: $scrolled->insert('end',$job_header,'RED') if ($job_header); $scrolled->insert('end',$running_proc,'BLUE') if ($running_proc); $scro...

RE: text in a widget, text-widget #2
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 => &...

Re: text in a widget, text-widget @ 1145998849
Intrah onat Diria .. Tue, 25 Apr 2006 13:55:44 -0700 , ****** wrote "Revera y": > of "unsubscribe ptk" to majordomo@lists.stanford.edu > If you wish to unsubscribe from this mailing list, send the message body > This message was posted through the Stanford campus mailing list server. > ++**=3D=3D > -++**=3D=3D--++**=3D=3D--++**=3D=3D--++**=3D=3D--++**=3D=3D--++**=3D=3D--= > > > > > ,=20 > , _________________ > , |---| > , | > , lead > , ::::::opthe > , oo,loent,uaha > , }, > ,...

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...

Re: Text over button widget #3
Tk::Compound says it's used to combine images/text/bitmaps adjacent to each other. So I could only add text next to the image. Whereas, I'm trying to add text on top of the image, just like a regular button without the -image. _________________________________________________________________ MSN Movies - Trailers, showtimes, DVD's, and the latest news from Hollywood! http://movies.msn.click-url.com/go/onm00200509ave/direct/01/ -++**==--++**==--++**==--++**==--++**==--++**==--++**== This message was posted through the Stanford campus mailing list server. If you wis...

Re: Scrolling in a text widget. #3
I put your code into this: use Tk; $mw = MainWindow->new; my $t = $mw->Scrolled('Text')->pack; $t->bind("<4>", sub{ $t->yview('scroll', $t->cget(-height)*-.5, 'units')}); $t->bind("<5>", sub{ $t->yview('scroll', $t->cget(-height)*.5, 'units')}); MainLoop; and it doesn't work. What did I do wrong? Thanks ~Brian Jennings ________________________________________________________________ The best thing to hit the Internet in years - Juno SpeedBand! Surf the Web u...

re: Confusing behavior regarding selected text in a text widget
This message is directed to whoever replied to my original post. I read it but it was deleted before I could reply. Thank you for your reply and explanation. I knew something was going on but didn't know that the text widget class binding would be triggered. I thought that overriding the widget instance would suffice. Something to learn about. Also, thanks for your observation on my "clipboard append" call- join should be used. By the way, your suggestions did the trick! Thanks again. Mike ...

highlight text in text widget
Hi, I am trying to make widget that displays text. I also want a search keywords available. The way I have envisioned is something similar to emacs search, i.e. it highlights all the occurrences of the keyword that you are interested in. I am trying to find out if that kind of highlighting be done in widget_text or some other widgets. Can anyone help? Thanks neon writes: > I am trying to make widget that displays text. I also want a search > keywords available. The way I have envisioned is something similar to > emacs search, i.e. it highlights all the occurrences of the keyword &g...

Re: (fwd) Predictive text entry widget #3
> Path: Lehigh.EDU!ptk > From: "Matt Tovey (SGI)" <Matt.Tovey@partner.bmw.de> > Newsgroups: comp.lang.perl.tk > Subject: Re: (fwd) Predictive text entry widget > Date: 25 Sep 2003 04:44:08 -0400 > Lines: 100 > Sender: news@Lehigh.EDU > Approved: @netnews.CC.Lehigh.EDU > Message-ID: <3F729785.4020607@partner.bmw.de> > NNTP-Posting-Host: fidoii.cc.lehigh.edu > > Hello, > > I've been playing with this code for a predictive text entry widget, > and > have come up with the following code (for a "mozilla&q...

Re: (fwd) manipulating a derived Tk::Text widget
On Feb 3, 2005, at 3:07 PM, Steve Lidie wrote: > Hi, > > Yesterday a question was asked how to filter Control-g > characters from printing. > > Well Marc Dashevsky had posted an earlier solution where > he made a new text package like this: > > ####################################################33 > package Tk::MyText; > require Tk::Text; > use base qw/Tk::Text/; > Construct Tk::Widget 'MyText'; > > sub InsertKeypress { > my($w, $char) = @_; > if (ord($char) < 27) { > print chr(ord($char) | 0x40),...

Re: PK Newbie Text Widget Question #3
On Dec 9, 2003, at 10:40 PM, Jack wrote: > ----- Original Message ----- > From: "Frank Merrow" <fmerrow@qualcomm.com> > To: <ptk@lists.Stanford.EDU> > Sent: Tuesday, December 09, 2003 3:54 PM > Subject: PK Newbie Text Widget Question > > >> However, what I'd really like to have happen is either that they >> split the >> space evenly OR that I be able to move the "split point" up and down, >> but I >> cannot seem to get either of those working. > #Try this.. > use Tk; > use Tk::A...

Problem with tk text widget in displaying Chinese characters, entry widget works fine.
Hi, There seems to be a problem with tk text widget. I am able to edit and see the chinese characters in both entry widget and text widget. When I move from one character to another using arrow key or mouse, it works fine in entry; But in text, it simply mess up. The problem could be that chinese characters are 2 bytes long and cursor moves 1 byte. The text interpreter might be combining the other byte of Chinese character with the 2 bytes of next chinese character. Do I have to change some setting for text widget and/ or install some patch? Thanks, Vikas Vikas Gupta schrieb: > Hi, >...

Web resources about - RE: text in a widget, text-widget @ 1146167556 #3 - comp.lang.perl.tk

Favorites Widget - Call & Text from the Notification Center on the App Store on iTunes
Get Favorites Widget - Call & Text from the Notification Center on the App Store. See screenshots and ratings, and read customer reviews.

Apple takes aim at the iOS 8 Notification Center widget from popular text capture app Drafts 4
Nearly three months after launching iOS 8, Apple is still fine tuning what developers can do with the new functionality.

App Watch: Plain old text and widgets
App Watch: Plain old text and widgets

Minimalist Text is Your All-in-one Widget Option
Is Minimalist Text the best minimalist app we’ve seen yet? That’s tough to say, but we definitely think it’s worth mentioning and giving a ton ...

7 Great text-based widgets, for those that would rather read their home screen
7 Great text-based widgets, for those that would rather read their home screen

Widget Watch: Mac ASCII Text with Figlet
Continuing on with what has turned into ASCII Sunday here at TUAW, a comment from Micah Cooper led me to FIGlet, which has been around roughly ...

Heapo Clipboard Management Widget - copy & paste text, photo and URL instantly also view, clear and sync ...
Get Heapo Clipboard Management Widget - copy & paste text, photo and URL instantly also view, clear and sync your clipboard with your desktop/mac/window ...

Apple takes aim at the iOS 8 Notification Center widget from popular text capture app Drafts 4
... decided that yet another iOS 8 Notification Center widget needs to be modified. Agile Tortoises Greg Pierce, developer of the popular text ...

Resources last updated: 2/6/2016 12:30:16 AM