Newbie - Saving text from text window 
Author Message
 Newbie - Saving text from text window

How do I save the text in a text window to a file with out using the
tk_getSaveFile command?


Sun, 25 Aug 2002 03:00:00 GMT  
 Newbie - Saving text from text window


Quote:
> How do I save the text in a text window to a file with out using the
> tk_getSaveFile command?

Hummm, so you don't care what the file name is?

set contents [.text get 1.0 end]

set file_id [open savefile w]

puts -nonewline $file_id $contents

close $file_id

Here .text is the text widget window path.

--brett

Sent via Deja.com http://www.deja.com/
Before you buy.



Mon, 26 Aug 2002 03:00:00 GMT  
 Newbie - Saving text from text window

Quote:


> > How do I save the text in a text window to a file with out using the
> > tk_getSaveFile command?

> set contents [.text get 1.0 end]

Don't forget that the text widget maintains an extra newline after the
data.  To get the contents of the widget without that extra \n, use:

  set contents [.text get 1.0 "end - 1 chars"]

Bob
--

Mayo Foundation                                           (507) 284-2702
Rochester MN, 55905 USA   http://www.mayo.edu/sppdg/sppdg_home_page.html



Mon, 26 Aug 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. saving and loading a text window with embedded windows

2. How to save text in a text widget?

3. How to save new text in text box

4. Newbie: Text Widget Save Problem-Help

5. Newbie ? - Starting Windows program/Sending text to window

6. Newbie quest.: text selection position in text widget??

7. Accessing text in other applications windows text boxes

8. OT: Windows Text vs DOS Text

9. scrolling text window when adding text at bottom.

10. Following new text in a text window

11. Some questions on elided text in the text widget (and a few other text widget questions)

12. Text editor that saves emphases?

 

 
Powered by phpBB® Forum Software