Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Strange behaviour of text widget
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Rob  
View profile  
 More options Feb 7, 4:48 am
Newsgroups: comp.lang.tcl
Followup-To: comp.lang.tcl
From: Rob <dislexic_wob...@NOSPAMyahoo.com>
Date: Tue, 07 Feb 2012 20:48:58 +1100
Local: Tues, Feb 7 2012 4:48 am
Subject: 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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Arjen Markus  
View profile  
 More options Feb 7, 5:27 am
Newsgroups: comp.lang.tcl
From: Arjen Markus <arjen.markus...@gmail.com>
Date: Tue, 7 Feb 2012 02:27:08 -0800 (PST)
Local: Tues, Feb 7 2012 5:27 am
Subject: Re: Strange behaviour of text widget
On 7 feb, 10:48, Rob <dislexic_wob...@NOSPAMyahoo.com> wrote:

While I am not sure why you get 176 as the outcome of the program
_without_ the "update idle" command, I do understand why there is a
difference. You get similar problems/variations when you try to
create a PostScript file with the contents of a canvas.

The thing is that the text widget has not been able to fully
accommodate
its contents with respect to the available geometry. Quite possibly,
as with the canvas, it has to assume that its size is minimal (in this
case: one character wide) until it can negotiate with the containing
widget what its size will be.

The "update idle" command causes this negotiation to occur rightaway.
Once it is done, the text widget can properly compute how many
characters
it can show at each display line.

Regards,

Arjen


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rob  
View profile  
 More options Feb 7, 8:23 am
Newsgroups: comp.lang.tcl
Followup-To: comp.lang.tcl
From: Rob <dislexic_wob...@NOSPAMyahoo.com>
Date: Wed, 08 Feb 2012 00:23:33 +1100
Local: Tues, Feb 7 2012 8:23 am
Subject: Re: Strange behaviour of text widget

Arjen

Thank you for the explanation. The 176 characters is the length of the input
string, so I was concerned that somehow the text widget was reverting to
counting the number of characters rather than the number of display lines
which I actually requested - so maybe a bug of some sort!

What you've said explains the behaviour perfectly.  Should a warning that
this sort of behaviour might occur be put into the documentation so a
developer using the text widget is prepared for what looks like a
behavioural problem (but as you've pointed out, is not!)? And the use of the
"update idle" command as a 'work around'.

        Rob


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »