Added a format option to the scale widget. The default
is the originally hard coded %.f
When the slider was at the min or max the displayed
value (with horizontal orientation) was being truncated.
Added some code so that when the value hit the side of
the widget it stays put until it can move with the slider
again- dont know if this the desired behaviour.
In vertical orientation the value is still being truncated-
need to widen the whole widget.
Thanks to Pat Thoyts for his suggestion: http://groups-
http://groups-
beta.google.com/group/comp.lang.tcl/browse_thread/thre
ad/45d2348c777e1304/
Goodwin
goodwin.lawlor@ucd.ie
scale -format patch
Logged In: NO
This patch just formats the display value... would be nice to
format the actual widget variable value aswell.
Goodwin
goodwin.lawlor@ucd.ie
Logged In: YES
user_id=68433
Problem here:
+ value_format =
Tcl_GetStringFromObj(scalePtr->scale.formatObj, &format_len);
+ sprintf(str, value_format, value);
This will cause Very Bad Things to happen if the user
specifies a "-format" option that isn't compatible with the
sprintf() call.
Logged In: YES
user_id=1323571
Though I would initially have expected bad things from an
incorrect "-format" option, the behavior I get is when "-
format" isn't a conversion specifier its simply displayed as
text. You can also mix a conversion specifier and text.
If you include more than one conversion specifier then its
included in the displayed text with a zero value
(eg)
::ttk::scale .s -from 0 -to 10
.s config -format "bad format" - the scale widget just
displays the text "bad format"
.s config -format "%.2f mm" - the widget value is correctly
formatted and displayed along with the text "mm" (eg "1.02
mm")
.s config -format "%.2f %.3f mm" - displayed value is "1.02
0.000 mm"