Connecting Tech Pros Worldwide Forums | Help | Site Map

text area problem

Newbie
 
Join Date: Oct 2008
Posts: 17
#1: Oct 22 '08
i want to highlight(select) text field in a text area in perl.is there any way to that

any help..........

KevinADC's Avatar
Expert
 
Join Date: Jan 2007
Location: Southern California USA
Posts: 4,091
#2: Oct 22 '08

re: text area problem


perl has no "text area". Can you explain your question better?
Newbie
 
Join Date: Oct 2008
Posts: 17
#3: Oct 22 '08

re: text area problem


Quote:

Originally Posted by KevinADC

perl has no "text area". Can you explain your question better?


i mean text box.i have made a text box using perl tk.i want to select some text inside the text box.how i do that.

thanks brother
nithinpes's Avatar
Expert
 
Join Date: Dec 2007
Posts: 400
#4: Oct 22 '08

re: text area problem


Quote:

Originally Posted by pradeeps

i mean text box.i have made a text box using perl tk.i want to select some text inside the text box.how i do that.

thanks brother

Using tag method, set a background color first. You can use this color to highlight text later. E.g
Expand|Select|Wrap|Line Numbers
  1. my  $tx= $fr->Scrolled( 'Text', '-scrollbars' => 'e', '-background' => 'white',       
  2.   )->pack( -fill => 'both', -expand => 1, -side => 'bottom' );
  3.  
  4. $tx->tag(qw/configure color1 -background yellow/); ##yellow for highlight
  5. $tx->insert('insert', "This is ");
  6. $tx->insert('insert',"highlighted text",'color1');
  7. $tx->insert('insert', "\n ");
  8.  
-Nithin
Newbie
 
Join Date: Oct 2008
Posts: 17
#5: Oct 22 '08

re: text area problem


thanks very much.i'm sorry.i've illustrate the question wrongly.

when i click the relevant text inside the text box it should select.when i click the text it should come another window that describes the properties of that text.that is the my question.if you don't understand pls tell me.i will explain.

thanks .cheers
Member
 
Join Date: Sep 2008
Posts: 57
#6: Oct 22 '08

re: text area problem


I dont understand what you want exatly ,but I give u 2 tips, I hope that help u



u can select a text widget in TK(set the cursor in this widget):


Expand|Select|Wrap|Line Numbers
  1. use Tk;    
  2. $mw->maxsize(500,800);                                
  3. $mw->minsize(500,800);
  4. $text=$mw->Text( -width=>65,
  5.                  -height=>5,
  6.          );
  7. $text->place(-x => 20,-y => 700);    
  8. $text->focus;    #set cursor to the chosen text widget
When u want take a line from text widget do this:


Expand|Select|Wrap|Line Numbers
  1. use Tk;    
  2. $mw->maxsize(500,800);                                
  3. $mw->minsize(500,800);
  4. $text=$mw->Text( -width=>65,
  5.                  -height=>5,
  6.          );
  7. $text->place(-x => 20,-y => 700);    
  8. #then u write to text widget
  9. $r=$text->get('1.0','1.0 lineend');       #take the first line from text
Member
 
Join Date: Sep 2008
Posts: 57
#7: Oct 22 '08

re: text area problem


u can also many line take(u think that field?)

Expand|Select|Wrap|Line Numbers
  1. @r=$text->get(’1.0’,’1.0 lineend’,’2.0’,’2.0 lineend’);
  2. #this get first second... lines from your text widget
results:
$r[0]="first line"
$r[1]="second line"
ect.
Newbie
 
Join Date: Oct 2008
Posts: 17
#8: Oct 23 '08

re: text area problem


thanks brother.i think u ve not understand my problem.

in my text box it is displayed some mac addresses as follows.

0x001cc48468c2
0x001635749100
0x00219bd81383
0x000bcd5f295c
0x000c29a59daa

when i double click on one of mac address then i want to pop up a new window.but i don t know is it possible in perl tk.
how i do that

thanks again............
Member
 
Join Date: Sep 2008
Posts: 57
#9: Oct 23 '08

re: text area problem


Quote:

Originally Posted by pradeeps

thanks brother.i think u ve not understand my problem.

in my text box it is displayed some mac addresses as follows.

0x001cc48468c2
0x001635749100
0x00219bd81383
0x000bcd5f295c
0x000c29a59daa

when i double click on one of mac address then i want to pop up a new window.but i don t know is it possible in perl tk.
how i do that

thanks again............


Why dont make a browseentry? In that can u chose a line and to assign a subrutin.
Newbie
 
Join Date: Oct 2008
Posts: 17
#10: Oct 28 '08

re: text area problem


ye it's also helped me.but i want is when i click on one mac address then it should come a new window.how i do that.i'm new to the perl.

any help greatly appreciated.........
Member
 
Join Date: Sep 2008
Posts: 57
#11: Oct 28 '08

re: text area problem


Quote:

Originally Posted by pradeeps

ye it's also helped me.but i want is when i click on one mac address then it should come a new window.how i do that.i'm new to the perl.

any help greatly appreciated.........

Expand|Select|Wrap|Line Numbers
  1. use Tk;
  2. $mw = MainWindow->new(-title => " Using BrowseEntry");
  3. $be = $mw->BrowseEntry(-variable => \$string,
  4.                                       -browsecmd => \&rutin);
  5. $be->pack();
  6. MainLoop();
  7. sub rutin
  8. {
  9.         $mw2 = MainWindow->new(-title => " New MainWindow");
  10. }
Reply