buttons are too big!

Skip to first unread message

Jonas Beskow

May 29, 1999, 3:00:00 AM5/29/99
Hello all,

Here's a protentially trivial problem that I have: how can I make a
button not take up any extra space height-wise?
The following case...

pack [label .l -text hello -relief raised] -side left
pack [button .b -text hello] -side left

...results in a button nearly twice as high as the label (on Windows at
least). Why the difference between buttons and other lables? The -height
option only takes integer # of lines. I guess I could make my own
buttons using lables, or use "place" rather than pack or grid, but this
sounds rather tedious... Is there an option to control this somewhere
that I'm missing?

Also, it doesn't actually seem quite consistent with the Win interface -
I just compared with the buttons in the Windows Find dialogue and they
are somewhat narrower...

- Jonas

Roy Terry

May 29, 1999, 3:00:00 AM5/29/99
Let me just repeat Bryan Oakleys response to similar questions two
weeks ago:
Re: TK / problem with height of button
Date: Wed, 12 May 1999 16:37:45 -0600
From: "Bryan Oakley" <oak...@channelpoint.com>
Organization: ChannelPoint, Inc.
Newsgroups: comp.lang.tcl
References: 1

Lahcene Si Ameur <lah...@bagh.com> wrote in message
> Hi,
> I would like to reduce to the maximun the height of buttons but TK
> always preserve a defaults height. Please someone can help me to resolve
> this problem ?

The height is based on the contents plus some borders and such. Are you
saying that, regardless of the contents (say, a label in a really big
you want the size to be constant, or are you saying the size is OK
for the extra padding added by tk?

If the latter, check out the -highlightthickness, -padx, -pady
and -borderwidth options. If the former, you can create a frame of the
preferred size and pack the button into that frame after turning
propagation off. To wit:

frame .foo -width 20 -height 20
pack propagate .foo off
button .b1 -text "Foo" -width 10 -height 2
pack .b1 -in .foo

Reply all
Reply to author
0 new messages