The New PerlTk.org - Save the contents of a Text widget
www.mamboteam.com
The New PerlTk.org  
Home
Thursday, 28 August 2014
 
 
Main Menu
Home
Perl/Tk Widgets
Articles
Scripts
Useful Tips
Links
Contact Us
Search
FAQs
Login Form
Username

Password

Remember me
Forgotten your password?
No account yet? Create one
Save the contents of a Text widget PDF Print E-mail
Contributed by Christiaan ter Veen   
To do this you can simple use $text->get('0.0', 'end') and save the result to a file but end refers to the newline after the last character so if you open the file in your Text widget and save it again it will add a newline at the end of the file everytime.

instead use $text->get('0.0', 'end - 1 chars') so the newline is removed.

In some versions of Tk::TextUndo the save method also adds the newline, you can adapt the code at line 718.

Comments
Written by gpm1982 on 2006-07-10 00:55:56
can we use chomp() instead, so that by using: 
 
Code:
 
chomp($input = $text->get('0.0', 'end'); 

 
 
we can get the text, minus the newline?

Only registered users can write comments.
Please login or register.

Powered by AkoComment 2.0!

< Prev   Next >
 
Top! Top!