Reading all user input from a Text Widget into an Array? 
Author Message
 Reading all user input from a Text Widget into an Array?

Hello Everyone,

      I'm sure this question has been asked before, however I could
not find much related to this subject under archives. Anyways, the
problem is that I'm trying to read all the input lines from a text

$textbox->get(1.0, end);"

  It failed. I don't know what else to think about. Any help will be
much appreciated. Thank You.

PS. Here is the actual code.

$frm_body = $mw->Frame() ->pack( -padx => 10, -pady => 5, -side =>
right);




Sun, 27 Mar 2005 03:32:17 GMT  
 Reading all user input from a Text Widget into an Array?

Quote:

> Hello Everyone,
>       I'm sure this question has been asked before, however I could
> not find much related to this subject under archives. Anyways, the
> problem is that I'm trying to read all the input lines from a text

> $textbox->get(1.0, end);"
>   It failed. I don't know what else to think about. Any help will be
> much appreciated. Thank You.
> PS. Here is the actual code.
> $frm_body = $mw->Frame() ->pack( -padx => 10, -pady => 5, -side =>
> right);
> $txt = $frm_body->Text( -width => 60, -height => 23)->pack;


Well, there's nothing in the Text widget (-: Oh, maybe that's not really
the actual code... will the real code please stand up.

What doesn't actually work?

Steve



Sun, 27 Mar 2005 03:41:52 GMT  
 Reading all user input from a Text Widget into an Array?

says...

Quote:
> Hello Everyone,

>       I'm sure this question has been asked before, however I could
> not find much related to this subject under archives. Anyways, the
> problem is that I'm trying to read all the input lines from a text

> $textbox->get(1.0, end);"

>   It failed. I don't know what else to think about. Any help will be
> much appreciated. Thank You.

> PS. Here is the actual code.

> $frm_body = $mw->Frame() ->pack( -padx => 10, -pady => 5, -side =>
> right);
> $txt = $frm_body->Text( -width => 60, -height => 23)->pack;


The get method returns a string, not an array.  Use:


--
  Marc Dashevsky -- Remove '_' from address if replying by e-mail.



Sun, 27 Mar 2005 04:31:50 GMT  
 Reading all user input from a Text Widget into an Array?

Quote:


> says...
> > Hello Everyone,

> >       I'm sure this question has been asked before, however I could
> > not find much related to this subject under archives. Anyways, the
> > problem is that I'm trying to read all the input lines from a text

> > $textbox->get(1.0, end);"

> >   It failed. I don't know what else to think about. Any help will be
> > much appreciated. Thank You.

> > PS. Here is the actual code.

> > $frm_body = $mw->Frame() ->pack( -padx => 10, -pady => 5, -side =>
> > right);
> > $txt = $frm_body->Text( -width => 60, -height => 23)->pack;

> The get method returns a string, not an array.  Use:



       Hi Marc, thanks for the suggestion but is not working. I tried
it.

       I'm using Perl 5.80 under Redhat 8.0 linux. Anyway, I'm going
to post the full program as it is currently. Basically, is a front-end
(GUI) to sendmail. Please any suggestions, tips, or anything to help
me solve this problem is welcome again. Thank you.

#!/usr/bin/perl
use Tk;
#Mandador v0.3

#VARIABLE LIBRARY. *NOTE* CHANGE SENDMAIL PATH IF NEEDED.
$sendmailpath = "/usr/sbin/sendmail";

#SENDMAIL PROCESS.
sub sendmail {
open (SENDMAIL, "| $sendmailpath -t");
print SENDMAIL "Subject: $input_subject\n";
print SENDMAIL "From: \"$input_s_name\" \<$input_s_address\>\n";
print SENDMAIL "To: $input_to\n\n";

close (SENDMAIL);

Quote:
}

#WINDOW CREATION PROCESS.
$mw = new MainWindow;
$mw->title( "Mandador v0.0.1" );

$frm_body = $mw->Frame() ->pack(-padx => 10, -pady => 40, -side =>
right, -anchor => 'n');
$txt = $frm_body->Text(-background => white, -relief => ridge, -width

$md = $mw->Label(-foreground => gray95, -text => "Mandador v.0.0.1\nby
Miguel Daniel") ->pack;

$frm1 = $mw->Frame() ->pack( -padx =>10, -pady => 5, -side => top,
-anchor => nw);
$t_label = $frm1->Label(-text => "Target E-mail  ") ->pack;
$t_entry = $frm1->Entry(-background => white, -textvariable =>
\$input_to) ->pack;

$frm2 = $mw->Frame() ->pack( -padx =>10, -pady => 5, -side => top,
-anchor => nw);
$tp_label = $frm2->Label(-text => "E-mail Subject  ") ->pack;
$tp_entry = $frm2->Entry(-background => white, -textvariable =>
\$input_subject) ->pack;

$frm3 = $mw->Frame() ->pack( -padx =>10, -pady => 5, -side => top,
-anchor => nw);
$inp_n_label = $frm3->Label(-text => "Your Full Name  ") ->pack;
$inp_n_entry = $frm3->Entry(-background => white, -textvariable =>
\$input_s_name) ->pack;

$frm4 = $mw->Frame() ->pack( -padx =>10, -pady => 5, -side => top,
-anchor => nw);
$inp_s_label = $frm4->Label(-text => "Sender's E-mail  ") ->pack;
$inp_s_entry = $frm4->Entry(-background => white, -textvariable =>
\$input_s_address) ->pack;

$frm_bu = $mw->Frame() ->pack( -pady => 5, -side => top);
$frm_bu->Button(-text => " Send ",
-relief => groove,
-command => sub {  &sendmail } ) ->pack (-ipadx =>40, -ipady => 2,
-padx =>10, -pady => 2);
$frm_bu->Button(-text => "  Exit  ",
-relief => groove,
-command => sub {  exit } ) ->pack(-ipadx =>40, -ipady => 2, -padx
=>10, -pady => 2);

$frm_status = $mw->Frame() ->pack( -padx => 5, -pady => 5, -anchor =>
sw);
$status = $frm_status->Label(-text => "Status: ") ->pack;

MainLoop;

Sincerely,
Miguel Daniel



Sun, 27 Mar 2005 10:44:36 GMT  
 Reading all user input from a Text Widget into an Array?

says...

Quote:
> $txt = $frm_body->Text(-background => white, -relief => ridge,
>    -width => 60, -height => 25, -wrap => 'word')->pack;


There's nothing in the text widget at the time you invoke get().
You need to have a procedure that gets the contents at the
appropriate time.  Keep in mind that get does not return an array.

--
  Marc Dashevsky -- Remove '_' from address if replying by e-mail.



Sun, 27 Mar 2005 10:57:16 GMT  
 Reading all user input from a Text Widget into an Array?

Quote:


> says...
> > $txt = $frm_body->Text(-background => white, -relief => ridge,
> >       -width => 60, -height => 25, -wrap => 'word')->pack;

> There's nothing in the text widget at the time you invoke get().
> You need to have a procedure that gets the contents at the
> appropriate time.  Keep in mind that get does not return an array.

Hello Marc,

   I see. Then how will I possibly be able to pack all that into an
array? spliting it into words may? I will try it as soon as possible.
By the way, I'm very new to the Tk module, and all I have with me with
is the "Learning Perl/TK" book, which as you may have tought it does
not mention much about the "get" function. In other words it does not
explain what the "get" function returned instead. Well thanks for you
help, I will post back to report the results.

-Miguel Daniel



Sun, 27 Mar 2005 18:53:52 GMT  
 Reading all user input from a Text Widget into an Array?

says...

Quote:


> > says...
> > > $txt = $frm_body->Text(-background => white, -relief => ridge,
> > >  -width => 60, -height => 25, -wrap => 'word')->pack;

> > There's nothing in the text widget at the time you invoke get().
> > You need to have a procedure that gets the contents at the
> > appropriate time.  Keep in mind that get does not return an array.

>    I see. Then how will I possibly be able to pack all that into an
> array? spliting it into words may?

Splitting on new-line characters is one way:


--
  Marc Dashevsky -- Remove '_' from address if replying by e-mail.



Sun, 27 Mar 2005 21:35:13 GMT  
 Reading all user input from a Text Widget into an Array?

Quote:


> says...


> > > says...
> > > > $txt = $frm_body->Text(-background => white, -relief => ridge,
> > > >     -width => 60, -height => 25, -wrap => 'word')->pack;

> > > There's nothing in the text widget at the time you invoke get().
> > > You need to have a procedure that gets the contents at the
> > > appropriate time.  Keep in mind that get does not return an array.

> >    I see. Then how will I possibly be able to pack all that into an
> > array? spliting it into words may?

> Splitting on new-line characters is one way:



Hello Again,

   It works, I found out what the problem was. As Marc said, it had to
be invoked from button, or anything else. As I had it, it was simply
sitting there. Anyways, the "split" function is not necessary, I tried
it without it and it sent the message(s) intact (as I wanted). All
there is left to say is thank you all for you help, I appreciated. Ok,
goodies...I'm finally back on track :). Bye.

-Miguel Daniel



Mon, 28 Mar 2005 03:01:58 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Read Text Widget into Array (PERL TK)

2. Trailing file input to Tk text widget

3. Output user input to a plain text file

4. Reading user input on Win32

5. More newbie questions (arrays, user input)

6. Reading all input from a Text Widget into an Array?

7. reading text field input

8. Read-only text widget tags.

9. text widget read-only?

10. Read-only Text Widget...

11. User input vs. machine input for validation

12. Print an array in a text widget

 

 
Powered by phpBB® Forum Software