Strange behaviour of text widget



I have written the following code which reproducibly causes a strange
result. The text string used as input is actually 176 characters long
(according to the 'string length' command). Just in case it matters, this
text string contains with no internal line breaks.

text .txt -width 55 -wrap word
label .lbl -bg cyan3

pack .lbl -side top -fill x
pack .txt -side left

set comment "Science fiction author, journalist, and all around futurist
Cory Doctorow believes the recent copyright battles are the opening salvo of
a larger war against general computers."

..txt delete 1.0 end
..txt insert 1.0 $comment

update idle

set txtLines [.txt count -displaylines 1.0 end]
puts $txtLines

.....
.....

When the 'update idle' line of code is *not* used, the output from the puts
statement is 176. When the update line IS used, the result is 4.

Given that I was trying to get the count of the display lines produced,
these outcomes are confusing. From the visual evidence (text box), 4 is
obviously the correct outcome.

I have no idea what is causing this strange behaviour so am posting it here
so someone with a detailed understanding of the internals behind the text
widget can see it and offer an explanation and indication of whether I
should post a bug report.

TIA

Rob.
.



Relevant Pages

  • Bound variables produce different result to fetching field by field
    ... we have come across the strangest problem and wondered if anyone else ... when we have a zero length character string that is NOT null ... version reports that the field is NULL. ... We also see a strange occurrence where sometimes the bound version ...
    (microsoft.public.data.odbc)
  • Re: Strange behaviour of text widget
    ... The text string used as input is actually 176 characters long ... When the 'update idle' line of code is *not* used, ... The thing is that the text widget has not been able to fully ...
    (comp.lang.tcl)
  • Re: DAO QueryDef - access thinks my column name is a parameter
    ... > It looks to me like access parses out the SQL finding to make them ... > parameters, but I have column names with strange names ... > compares a field's value to a string, and the string has lots of strange ... > Alex Black ...
    (microsoft.public.access.queries)
  • Re: works on console but not when writing to a string or file
    ... I would think that what's strange is that your code doesn't work, not that some other code does. ... System.Console.Write(Encoding.ASCII.GetString(data, offset, ... in the outputdata string the last packets gets chopped off. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: CListBox::DrawItem code
    ... That is really strange, but GetText returns me the same crap like getting ... I mean I pass some string using AddString. ... > But that really defeats the purpose of having an owner draw listbox, ... > to change the data that you are keeping in the itemData to include the ...
    (microsoft.public.vc.mfc)