Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

centering 2 buttons...

6 views
Skip to first unread message

Greg Trafton

unread,
Jun 3, 1996, 3:00:00 AM6/3/96
to

Hi, all. I have two buttons I'd like centered and am having a heck of
a time doing it. I'm sure this should be easy, but no luck so far.

here's what I'm trying to do:

button $w.ok -text "OK"
button $w.cancel -text "Cancel"

pack $w.ok $w.cancel -side left -fill x

I'd like the OK and Cancel butons centered. Unfortunately, the
packing space for them is rather big (about 5x the length of both
buttons), and I'd like them centered within the packing space.

Suggestions anyone?

many thanks!
greg
--
Greg Trafton
(tra...@itd.nrl.navy.mil)

Bryan Oakley

unread,
Jun 3, 1996, 3:00:00 AM6/3/96
to Greg Trafton

Greg Trafton wrote:

Hi, all. I have two buttons I'd like centered and am having a heck of
a time doing it. I'm sure this should be easy, but no luck so far.

here's what I'm trying to do:

button $w.ok -text "OK"
button $w.cancel -text "Cancel"

pack $w.ok $w.cancel -side left -fill x

I'd like the OK and Cancel butons centered. Unfortunately, the
packing space for them is rather big (about 5x the length of both
buttons), and I'd like them centered within the packing space.

Suggestions anyone?

Does this do what you want?

# for illustrative purposes...
text .text
pack .text -side top

# create a frame for the buttons, then create the buttons
# inside that frame
frame .options
button .options.ok -text ok -width 5
button .options.cancel -text cancel -width 5
pack .options.ok .options.cancel -side left -expand n -fill none

pack .options -side bottom -anchor n

--
Bryan Oakley, Software Engineer
Healthcare Communications, Inc.
oak...@healthcare.com

Sandeep V. Tamhankar

unread,
Jun 4, 1996, 3:00:00 AM6/4/96
to tra...@hci24.itd.nrl.navy.mil

tra...@hci24.itd.nrl.navy.mil (Greg Trafton) wrote:
----snip-----

>here's what I'm trying to do:
>
> button $w.ok -text "OK"
> button $w.cancel -text "Cancel"
>
> pack $w.ok $w.cancel -side left -fill x
>
>I'd like the OK and Cancel butons centered. Unfortunately, the
>packing space for them is rather big (about 5x the length of both
>buttons), and I'd like them centered within the packing space.
----snip---


If $w were packed with a "-fill x", take out the "-fill x". After that,
I'd say the only thing left is take out the "-fill x" from the above.
The result should be two buttons centered in your window.

Hope this helps.
-----------------
Sandeep V. Tamhankar
Analysis Technician
Signaling Capabilities Analysis

The statements herein contained are my own and not those of my company.

e-mail: stam...@notes.cc.bellcore.com
WWW: http://stos-www.cit.cornell.edu/Sandeep_html/Sandeep.html

0 new messages