From: tom.rmadilo on
On Feb 8, 4:00 pm, "tom.rmadilo" <tom.rmad...(a)gmail.com> wrote:
> On Feb 8, 2:17 pm, Erik Leunissen <l...(a)the.footer.invalid> wrote:
>
> > tom.rmadilo wrote:
>
> > > Actually I think the extra two pixels comes from the room needed for
> > > the pressed button motion, which moves the image down and to the
> > > right.
>
> > That might be the case, and actually, this had crossed my mind too for a
> > moment.
>
> > But then, why is it different on Windows (where buttons have the same
> > image action)?
>
> My guess...I've been struggling with the same issue, so I would really
> like to know...is that the [winfo height/width] thing isn't
> necessarily a good way to measure the result of the widget creation.
>
> For instance, if I enlarge or shrink the window, the [winfo height/
> width] changes, although the button remains the same size.
>
> I did the same test using ttk widgets and I get the same problem: one
> or two extra pixels in space all the way around. On linux, the default
> ttk button doesn't move:
>
> package require Tcl 8.5
> package require Tk 8.5
>
> ttk::style theme use default
>
> image create photo img -file ./favicon.gif -height 16 -width 16
>
> ttk::button .b  -image img -style B.TButton
> .b configure -padding {0 0 0 0}
>
> ttk::style configure B.TButton -relief flat -padding {0 0 0 0} -width
> -1 -shiftrelief -1
> pack .b
>
> update idletasks
>
> winfo width .b
> winfo height .b
>
> I get 19 (16+3) for winfo width/height.

I just edited the ttk/defaults.tcl file:

ttk::style configure "." \
-borderwidth 0 \
....

Using the above script and with -borderwidth set to zero in the
default theme, I get [winfo height/width] = 17, one extra pixel col/
row on the left and top. On button press the image moves up and left.
This seems to be the minimum possible setting.

From: Erik Leunissen on
Jonathan Bromley wrote:
> On Mon, 08 Feb 2010 23:10:08 +0100, Erik Leunissen wrote:
>
>>> -borderwidth, -relief
>>
>>Please note the "-bd 0" in my original post.
>
> did you also set "-highlightthickness 0" ?
> I think it's set to 2 by default on a canvas;
> don't know about anything else. Its existence
> can do unexpected things to a canvas coordinate
> system.

Please note the "-highlightthickness 0" in my original post.

Erik.


--
leunissen@ nl | Merge the left part of these two lines into one,
e. hccnet. | respecting a character's position in a line.
From: tom.rmadilo on
On Feb 9, 9:03 am, Erik Leunissen <l...(a)the.footer.invalid> wrote:
> Jonathan Bromley wrote:
> > On Mon, 08 Feb 2010 23:10:08 +0100, Erik Leunissen wrote:
>
> >>> -borderwidth, -relief
>
> >>Please note the "-bd 0" in my original post.
>
> > did you also set "-highlightthickness 0" ?
> > I think it's set to 2 by default on a canvas;
> > don't know about anything else.  Its existence
> > can do unexpected things to a canvas coordinate
> > system.
>
> Please note the "-highlightthickness 0" in my original post.

Have you tested this, or are you just making a suggestion? When I add
this option to my last posted code, I get 17 for an image which is
16x16. The one extra pixel seems to allow the image to "move" when
pushed.
From: Ralf Fassel on
* Erik Leunissen <look(a)the.footer.invalid>
| % pack [button .b -width 20 -height 20 -image img -bd 0
| -highlightthickness 0 -padx 0 -pady 0]
| % update idletasks ;# probably only necessary if executed non-interactively
| % winfo width .b
| 22
| % winfo height .b
| 22
|
| Any ideas ?

unix/tkUnixButton.c has this code at the end of TkpComputeButtonGeometry():

if ((butPtr->type == TYPE_BUTTON) && !Tk_StrictMotif(butPtr->tkwin)) {
width += 2;
height += 2;
}

Indeed, if I set tk_strictMotif, I get the specified width/height:

% set tk_strictMotif 1
1
% image create photo img
img
% pack [button .b -width 20 -height 20 -image img -bd 0 -highlightthickness 0 -padx 0 -pady 0]
% winfo width .b
20
% winfo height .b
20

% destroy .b
% set tk_strictMotif 0
0
% pack [button .b -width 20 -height 20 -image img -bd 0 -highlightthickness 0 -padx 0 -pady 0]
% winfo width .b
22
% winfo height .b
22

HTH
R'
From: Erik Leunissen on
tom.rmadilo wrote:
> On Feb 9, 9:03 am, Erik Leunissen <l...(a)the.footer.invalid> wrote:
>> Jonathan Bromley wrote:
>> > On Mon, 08 Feb 2010 23:10:08 +0100, Erik Leunissen wrote:
>>
>> >>> -borderwidth, -relief
>>
>> >>Please note the "-bd 0" in my original post.
>>
>> > did you also set "-highlightthickness 0" ?
>> > I think it's set to 2 by default on a canvas;
>> > don't know about anything else. Its existence
>> > can do unexpected things to a canvas coordinate
>> > system.
>>
>> Please note the "-highlightthickness 0" in my original post.
>
> Have you tested this, or are you just making a suggestion?

I'm puzzled about this question. I don't understand why you ask
(especially now in this discussion). The original post says what I
actually did.

Erik.

When I add
> this option to my last posted code, I get 17 for an image which is
> 16x16. The one extra pixel seems to allow the image to "move" when
> pushed.


--
leunissen@ nl | Merge the left part of these two lines into one,
e. hccnet. | respecting a character's position in a line.