# TK padx question

**URL:** <https://www.ruby-forum.com/t/tk-padx-question/141528>\
**Category:** Ruby\
**Created:** [June 26, 2008, 7:48pm UTC](https://www.ruby-forum.com/t/tk-padx-question/141528 "2008-06-26T19:48:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubyman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecc23a/32.png) [@rubyman](https://www.ruby-forum.com/u/rubyman)\
**Post date:** [June 26, 2008, 7:48pm UTC](https://www.ruby-forum.com/t/tk-padx-question/141528/1 "2008-06-26T19:48:30Z")

</div>

Hello,

I was wondering if anyone knows how to specify a list of two values for  
:padx - I have been using “:padx=\>5” for example, in positioning a  
button  
widget inside a frame that holds four buttons. I have been reading  
online  
that you can specify a list of two values when you want to pad on the  
left  
and right using different values.

Unfortunately, I cannot locate any examples that show the correct  
syntax.  
Anyone know how to specify this?

Thanks,

Harry

---

<div class="post-metadata">

**Author:** ![rubyman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecc23a/32.png) [@rubyman](https://www.ruby-forum.com/u/rubyman)\
**Post date:** [June 27, 2008, 12:13am UTC](https://www.ruby-forum.com/t/tk-padx-question/141528/2 "2008-06-27T00:13:48Z")

</div>

From: “Harry T.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: TK padx question  
Date: Fri, 27 Jun 2008 02:45:22 +0900  
Message-ID: [002601c8d7b4$b5db6a80$removed\_email\_address@domain.invalid](mailto:002601c8d7b4$b5db6a80$removed_email_address@domain.invalid)

> I was wondering if anyone knows how to specify a list of two values for  
> :padx - I have been using “:padx=\>5” for example, in positioning a button  
> widget inside a frame that holds four buttons. I have been reading online  
> that you can specify a list of two values when you want to pad on the left  
> and right using different values.

There are some examples under “/ext/tk/sample” directory.  
For example, “demos-en/image3.rb” uses “:padx=\>[0, ‘2m’]”.

Fundamentally, when Tcl/Tk requires a list of values,  
please give an array on Ruby/Tk.  
If the rule doesn’t work, it must be a bug.

As a similar rule, when Tcl/Tk requires a list  
“-option val -option val …”, please give a hash  
{option=\>val, option=\>val, …} on Ruby/Tk.

## “font” option may be a good example.

Tcl/Tk: button .b -font {Times 14 bold underline}  
v  
Ruby/Tk: TkButton.new(:font=\>[‘Times’, 14, ‘bold’, ‘underline’])  
TkButton.new(:font=\>%w(Times 14 bold underline))  
TkButton.new(:font=\>[‘Times’, 14, :bold, :underline])  
# A symbol is converted to a string.  
TkButton.new(:font=\>“Times 14 bold underline”)  
# Tcl/Tk’s list is a string, So this is also available.

Tcl/Tk: button .b -font {-family Times -size 14 -weight bold -underline  
true}  
v  
Ruby/Tk: TkButton.new(:font=\>{:family=\>‘Times’, :size=\>14,  
:weight=\>‘bold’, :underline=\>true])  
TkButton.new(:font=\>{‘family’=\>‘Times’, ‘size’=\>14,  
‘weight’=\>‘bold’, ‘underline’=\>true])  
# Both of a symbol and a string are available for keys.  
TkButton.new(:font=\>“-family Times -size 14 -weight bold  
-underline true”)  
# Of course, this is OK.
