saving from a menu bar



Hi all,

Im new to perl-gtk and i have been editing the text widget example from
the gtk-perl tutorial on the web.
I could make a "save" button that saves the whole textfile to disk, but
that aint fun.
So i created a menu with the help of that tutorial.
Here is a snip:
........
{ path        => '/File/_Save',
                         accelerator => '<control>S',
                         callback    => \&save, $window,$text },
.....

and here is the subroutine:

sub save {
        my ($widget, $window,  $text) = @_;
        my $entry_text = $text->get_chars();
        open (FILE, ">$textfile");
        print FILE "$entry_text\n";
        close FILE;
}

This complains cos im not pasing the right stuff to the subroutine
("Can't call method "get_chars" on an undefined value at ...")

How do i pass the right stuff in the callback?

Thanks.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]