Re: open and saveing files

Todd Littlefield <[email protected]> Sat, 16 Sep 2006 17:16:45 -0500
Newsgroups gmane.comp.lang.perl.tk
Message-ID <[email protected]>
Hi Jeevitesh,

    That is the correct behavior.  If you look closely at the methods 
you have
called, they only return the strings to the file you selected for opening or
are trying to save...

    It is up to your code to then call the perl open function.  At that 
point you
will have a file handle that can be read from and written to...  Once 
you have the
contents, you will need to use the insert method on the text widget to write
to the screen and the get method to retrieve the text and then use the print
or other method to put it into the save file...

    Don't forget to close the filehandles when you are done.  perl will 
do that
automatically but in GUI code there's no telling when you might try to reuse
a filehandle and that will give you unpredictable results...

    Check the perl documentation for all the methods/functions.  
Everything you
need to know about them is in there...  (the easiest method is to 
install ActivePerl
and grab their html folder...  they have done a great job of setting it 
up and is
pretty easy to use.)

    Good luck.

- Todd


jeevitesh wrote:
>
> Dear friends,
>
> I need you help to open the file in the text area and save contents of 
> the corresponding Text area. I have used this following code which 
> call separately subroutines when corresponding button are pressed. But 
> the problem with this code is two windows are generated but it will 
> not save or open the selected files.
>
> sub openfiles()
>
> {
>
>    $top = new MainWindow;
>
>     $top->getOpenFile;
>
> }
>
>  
>
> sub savefile()
>
> {
>
>     $top = new MainWindow;
>
>     $top->getSaveFile;
>
> }
>
>  
>
> With regards
>
--++**==--++**==--++**==--++**==--++**==--++**==--++**==
ptk mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/ptk