TkParsePadAmount manually parses through -padx/-pady
values as a string, and fails to properly handle
whitespace in the process, rather than treating the
argument as a list object. This results in 'bad screen
distance ""' errors if you do e.g.:
pack $w -pady { 5 0 }
...or...
pack $w -pady [list 5 0]
...instead of...
pack $w -pady {5 0}
Attached is a patch to correct the problem versus head,
which should also be safe for 8.4 (TkParsePadAmount is
the same in the two branches).
Patch TkParsePadAmount to treat argument as list object
Logged In: YES
user_id=498198
[list 5 0] may actually be okay, but { 5 0 } definitely is not.
Logged In: YES
user_id=191079
The bug was due to fail to handle the leading spaces. To
avoid converting the input string to a list, I only fix the bug
by adding code to pass the leading spaces at the beginning.
The patch works fine but requires converting the input string
to a list first. It may be less efficient than processing the
input string directly. However, if this is not the case, then
the patch should be used.
Logged In: YES
user_id=498198
I ran some benchmarks with both patches and it seems to
favor one or the other depending on the form of the pad
list, but only +/- a microsecond or two per iteration (in
500k tested). I did use a proc for the packing, which may
affect the results (I would guess that it might only need
conversion to a list once in a proc, but I'm not certain).
I really don't like the way it modifies the string by
inserting a null byte, though, and a little testing reveals
a bug in that too!
% set foo {foo bar}
foo bar
% puts $foo
foo bar
% button .b
.b
% pack .b -padx $foo
bad pad value "foo": must be positive screen distance
% puts $foo
foobar
The value of foo has magically changed. Oops!
Unified diff against 8.4 branch tip
Logged In: YES
user_id=79902
Fixed (in 8.4 branch and HEAD) with attached patch. Note
that this version should be faster than the original one
because it won't shimmer in at least one common case. It
also cleans up the location of the code.
Logged In: YES
user_id=32170
Now the padx/pady code doesn't handle non-lists!!
% frame .msg
% pack .msg -padx 3m -pady 3m
wrong number of parts to pad specification
This works in tk 8.4.9/8.5a2.
Logged In: YES
user_id=79902
D'oh!