On 8.5a5:
canvas .c ; pack .c
.c create text 4 4 -anchor nw -width 10 -text "This is a test."
On MacOS X (unsure of other platforms) this produces
This
is
a
test.
Given the width of 15 and the (reasonable) documented behavior to break only if next word would exceed line length, this should be:
This is a
test.
Logged In: YES
user_id=988604
Originator: NO
From the manual:
"-width lineLength
Specifies a maximum line length for the text, in any of the forms described in the COORDINATES section above."
...and...
"All coordinates related to canvases are stored as floating-point numbers. Coordinates and distances are specified in screen units, which are floating-point numbers optionally followed by one of several letters. If no letter is supplied then the distance is in pixels. If the letter is m then the distance is in millimeters on the screen; if it is c then the distance is in centimeters; i means inches, and p means printers points (1/72 inch). Larger y-coordinates refer to points lower on the screen; larger x-coordinates refer to points farther to the right. Coordinates can be specified either as an even number of parameters, or as a single list parameter containing an even number of x and y coordinate values."
In effect, the value of 10 in your example is interpreted as 10 pixels. Try other letters to achieve different effects, but as far as I can see, there is no option to indicate interpretation as "number of character" as you are perhaps expecting.
Logged In: YES
user_id=146959
Originator: YES
Sorry, you're right, I'm an idiot. ;)
My only excuse is text widgets go by chars and I'd just switched some code from one..
Logged In: YES
user_id=79902
Originator: NO
I think you'll find that [font measure] might be useful in getting the width that you actually require.