From: Erik Leunissen on
Hello all,

Ahem, ...

This is so basic, that I must be prepared to be embarrassed by the
explanation. Well, so be it:

It appears that I am unable to generate a Tk button whose actual size is
the same as the size indicated by the options -width and -height.

That is, under Linux I can't; under Windows: no problem.

I've spent a few hours to find any interference (of ~/.wishrc,
~/.tclshrc, ~/.Xdefaults): unsuccesfully. I'm out of ideas.

Below you can find the interactive session that creates a button of
intended size 20x20 pixels. After the widget has been mapped, [winfo
width] and [winfo height] both return 22:


% image create photo img -file ./Done.gif ;# any gif image is OK, this
one is 12x12 pixels
img
% 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 ?

Thanks in advance,

Erik
--
leunissen@ nl | Merge the left part of these two lines into one,
e. hccnet. | respecting a character's position in a line.
From: Roy Terry on
On Feb 7, 11:56 am, Erik Leunissen <l...(a)the.footer.invalid> wrote:
> Hello all,
>
> Ahem, ...
>
> This is so basic, that I must be prepared to be embarrassed by the
> explanation. Well, so be it:
>
> It appears that I am unable to generate a Tk button whose actual size is
> the same as the size indicated by the options -width and -height.
>
> That is, under Linux I can't; under Windows: no problem.
>
> I've spent a few hours to find any interference (of ~/.wishrc,
> ~/.tclshrc, ~/.Xdefaults): unsuccesfully. I'm out of ideas.
>
> Below you can find the interactive session that creates a button of
> intended size 20x20 pixels. After the widget has been mapped, [winfo
> width] and [winfo height] both return 22:
>
> % image create photo img -file ./Done.gif ;# any gif image is OK, this
> one is 12x12 pixels
> img
> % 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 ?
>
> Thanks in advance,
>
> Erik
> --
>   leunissen@       nl | Merge the left part of these two lines into one,
> e.          hccnet.   | respecting a character's position in a line.

This area has gotten some changes from time to time. My recollection
from several years ago is that buttons displaying images will
completely ignore the -height and -width settings. My current Tk help
file does not confirm this, but is that not the behavior you are
seeing on Linux?
From: George Petasis on
στις 7/2/2010 21:56, O/H Erik Leunissen έγραψε:
> Hello all,
>
> Ahem, ...
>
> This is so basic, that I must be prepared to be embarrassed by the
> explanation. Well, so be it:
>
> It appears that I am unable to generate a Tk button whose actual size is
> the same as the size indicated by the options -width and -height.
>
> That is, under Linux I can't; under Windows: no problem.
>
> I've spent a few hours to find any interference (of ~/.wishrc,
> ~/.tclshrc, ~/.Xdefaults): unsuccesfully. I'm out of ideas.
>
> Below you can find the interactive session that creates a button of
> intended size 20x20 pixels. After the widget has been mapped, [winfo
> width] and [winfo height] both return 22:
>
>
> % image create photo img -file ./Done.gif ;# any gif image is OK, this
> one is 12x12 pixels
> img
> % 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 ?
>
> Thanks in advance,
>
> Erik

Can you try with -width 20p -height 20p ?

George
From: George Petasis on
στις 7/2/2010 21:56, O/H Erik Leunissen έγραψε:
> Hello all,
>
> Ahem, ...
>
> This is so basic, that I must be prepared to be embarrassed by the
> explanation. Well, so be it:
>
> It appears that I am unable to generate a Tk button whose actual size is
> the same as the size indicated by the options -width and -height.
>
> That is, under Linux I can't; under Windows: no problem.
>
> I've spent a few hours to find any interference (of ~/.wishrc,
> ~/.tclshrc, ~/.Xdefaults): unsuccesfully. I'm out of ideas.
>
> Below you can find the interactive session that creates a button of
> intended size 20x20 pixels. After the widget has been mapped, [winfo
> width] and [winfo height] both return 22:
>
>
> % image create photo img -file ./Done.gif ;# any gif image is OK, this
> one is 12x12 pixels
> img
> % 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 ?
>
> Thanks in advance,
>
> Erik

Can you try with -width 20p -height 20p ?

George
From: Erik Leunissen on
Roy Terry wrote:
>
> This area has gotten some changes from time to time. My recollection
> from several years ago is that buttons displaying images will
> completely ignore the -height and -width settings. My current Tk help
> file does not confirm this, but is that not the behavior you are
> seeing on Linux?

Experimentation shows that the widget options are not being ignored: the
actual button sizes obtained with my sample script are always exactly 2
pixels larger than I indicate through the widget options.

Thanks anyway for your attention,

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