text delete hangs in Perl/Tk
Anonymous Monk
created: 2004-07-01 13:59:00
I'm running into a problem where a call like: $text->delete("1.0","end"); (where $text is a valid Text widget) hangs my script. Has anyone run into this before? The text contains several thousand lines with as many as ~1000 characters per line. Each line may contain multiple tags as well. I'm 100% positive that the hang-up is coming during the call to delete. (i.e. I'm using $| = 1) Any ideas?
Re: text delete hangs in Perl/Tk
created: 2004-07-01 15:43:45
Your syntax is correct: "$text->delete("1.0", 'end');". Are you sure that your script is hung or might it just be that the amount of text between your indexes is that large ("several thousand lines with as many as ~1000 characters per line")?

Perhaps if you provided us with the block of code around where you think it is hanging it might help. You could be wrong as to the cause. . .

- - arden.
TMI is better than NEI in the tech-help world!

Re^2: text delete hangs in Perl/Tk
created: 2004-07-01 15:58:47
Unfortunately, the call is buried within a couple thousand lines of widget code and it would be difficult to provide a block that would provide enough context.

My main clue is that if I don't Add the tags to the text, the delete seems to work fine. Is it possible that if I've associated an invalid tag location with the text that it would cause delete to stall? Or perhaps I should be Removing all the tags before I try to delete the text lines with which they are associated? I have been operating under the assumption that the tags just "magically disappear" when you delete the text out from under them...

Re^3: text delete hangs in Perl/Tk
created: 2004-07-02 07:40:59
It is possible that there is some non-optimized code in the Tk core in some special situations. Can you check if it is faster if you delete the tags (either with tagDelete or tagRemove) before deleting the contents?
Re: text delete hangs in Perl/Tk
created: 2004-07-02 08:02:25
This was just recently discussed on comp.lang.perl.tk. One suggestion was to upgrade to the latest version, since older Tk's had a problem. The other, which I also suggest, is to use the Contents method:
 $text->Contents("")
           Query or change the entire contents of the text wid-
           get. If no arguments are given, the entire contents of
           the text widget are returned. If any arguments are
           given, the entire contents of the text widget are
           deleted and replaced by the argument list.


I'm not really a human, but I play one on earth. flash japh
Re^2: text delete hangs in Perl/Tk
created: 2004-07-02 14:06:49
Well, Contents() also does $w->delete('1.0','end');, so it won't help the original poster.

perlmonks.org content © perlmonks.org and Anonymous Monk, arden, eserte, zentara

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03