TK padx question

H

Harry Truax

[Note: parts of this message were removed to make it a legal post.]

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
 
H

Hidetoshi NAGAI

From: "Harry Truax" <[email protected]>
Subject: TK padx question
Date: Fri, 27 Jun 2008 02:45:22 +0900
Message-ID: said:
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 "<ruby-src>/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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top