tags:

views:

25

answers:

1

I have written a script that gets a file name and insert the file content to a Text widget. Now when I close the script window, I need it to write the text onto the Unix screen.

How can I get the Text widget content?

My text widget insertion sorce code is:

open(FILE, $file_name);
foreach my $line (<FILE>) {
    $text->insert('end', $line);
}
+2  A: 
$text->get('1.0','end-1c');

(It's end-1c – end less one character – for fairly technical reasons; with just end you'd get an extra newline appended. A known Tk gotcha.)

Donal Fellows
BTW, how you write it to the screen is up to you; there's *lots* of ways to do that…
Donal Fellows