Jack D replied:
>
> I am studying Tk using "Mastering Perl TK". I found the below listed code
> in the book and got it working,
>
> Added some stuff to it and it seems to be working OK. I wanted to add
> "$textundo->Save(?pathname?)
>
> so that it saves the contents of the widget to a file. I want this to
> happen when
>
> I click on the "Save" button. I have tried several things but can't get
> it to work.
>
> Any help would be deeply appreciated.
>
> The file path is "C:/save".
Well, if you want to use the Save method, then at a minimum you need to
use Tk::TextUndo;
I hope you are not expecting to be able to save the Entry widget data using
this method? If you wish to save that you will have to write your own
subroutine to "get" the input and save it separately.
>
> #!/usr/bin/perl
>
> use Tk;
use Tk::TextUndo;
> $mw = MainWindow->new;
> $mw->title("Text: Data Entry");
> $f = $mw->Frame->pack(-side => 'bottom');
> $f->Button(-text => "Exit",
> -command => sub {exit;})->pack(-side => 'left');
>
> $f->Button(-text => "Save",
> -command => sub { &print_rec;
> })->pack(-side => 'bottom');
>
> ####$t = $mw->Scrolled("Text", -width => 40,
$t = $mw->Scrolled("TextUndo", -width => 40,
> -wrap => 'none')->pack(-expand => 1, -fill =>
> 'both');
> foreach (qw/Name Address City State Zip Phone Occupation
> Company Business_Address Business_Phone/) {
> $w = $t->Label(-text => "$_:", -relief => 'groove', -width =>
> 20);
> $t->windowCreate('end', -window => $w);
> %info;
> $w = $t->Entry(-width => 20, -textvariable => \$info{$_});
> $t->windowCreate('end', -window => $w);
> $t->insert('end', "\n");
> }
> #$t->configure(-state => 'disabled'); # disallows user typing
> sub print_rec() {
> @key = keys %info;
> foreach $_ (@key) {
> print "$_:$info{$_}\n";
> }
$t->Save("C:/save.txt");
> }
>
> MainLoop;
>
Jack
Jack,
What I was trying to do was get an understanding of how to use and
Set up the "$textundo->Save(?pathname?)" method. My book
showed several of them but not how to set them up.
Thanks much for the info.
Eric
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs