in reply to uninitialized value using a Tk Text widget

I think it's a weird bug in the way a common $TOP window is used in the widget demo. I saw the bug exactly as you described it, in the widget demo; BUT I took the exact code out of the demo and put it into a standalone window... and there is no problem. So I'm guessing the Text.pm could use an $self->update, or something similar) to get the scrollbars to reset their internal marker to 0,0. It seems that the up/down arrows are trying to define the next/previous line in that sub at 1223, but after deleting all text, there is no next previous line, and the Text widget (or the Scrolled element) wasn't notified because of the way the widget demo is windowed.

You might ask on comp.lang.perl.tk.

The following code is a chopped down version, and dosn't show the problem.

By The Way, Nick is passed away, and Slaven Rezsic has pretty much taken over..... he reads comp.lang.perl.tk when he can.

#!/usr/bin/perl use Tk; my $mw = MainWindow->new(); my $TOP = $mw->Toplevel( ); &texts; MainLoop; # texts.pl sub texts { my $t = $TOP->Scrolled(qw/Text -relief sunken -borderwidth 2 -setgrid +true -height 30 -scrollbars e/); $t->pack(qw/-expand yes -fill both/); $t->insert('0.0', 'This window is a text widget. It displays one +or more lines of text and allows you to edit the text. Here is a summary of the things you can do to a text widget: 1. Scrolling. Use the scrollbar to adjust the view in the text window. 2. Scanning. Press mouse button 2 in the text window and drag up or do +wn. This will drag the text at high speed to allow you to scan its content +s. 3. Insert text. Press mouse button 1 to set the insertion cursor, then type text. What you type will be added to the widget. 4. Select. Press mouse button 1 and drag to select a range of characte +rs. Once you\'ve released the button, you can adjust the selection by pres +sing button 1 with the shift key down. This will reset the end of the selection nearest the mouse cursor and you can drag that end of the selection by dragging the mouse before releasing the mouse button. You can double-click to select whole words or triple-click to select whole lines. 5. Delete and replace. To delete text, select the characters you\'d li +ke to delete and type Backspace or Delete. Alternatively, you can type n +ew text, in which case it will replace the selected text. 6. Copy the selection. To copy the selection into this window, select what you want to copy (either here or in another application), then click button 2 to copy the selection to the point of the mouse cursor. 7. Edit. Text widgets support the standard Motif editing characters plus many Emacs editing characters. Backspace and Control-h erase the character to the left of the insertion cursor. Delete and Control-d erase the character to the right of the insertion cursor. Meta-backsp +ace deletes the word to the left of the insertion cursor, and Meta-d delet +es the word to the right of the insertion cursor. Control-k deletes from the insertion cursor to the end of the line, or it deletes the newline character if that is the only thing left on the line. Control-o opens a new line by inserting a newline character to the right of the insert +ion cursor. Control-t transposes the two characters on either side of the insertion cursor. 7. Resize the window. This widget has been configured with the "setGr +id" option on, so that if you resize the window it will always resize to a +n even number of characters high and wide. Also, if you make the window narrow you can see that long lines automatically wrap around onto additional lines so that all the information is always visible.'); $t->mark(qw/set insert 0.0/); } # end texts

I'm not really a human, but I play one on earth Remember How Lucky You Are