# Ruby TK GUI question

**URL:** <https://www.ruby-forum.com/t/ruby-tk-gui-question/69691>\
**Category:** Ruby\
**Created:** [February 17, 2006, 3:04pm UTC](https://www.ruby-forum.com/t/ruby-tk-gui-question/69691 "2006-02-17T15:04:19Z")\
**Posts on this page:** 3\
**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:** [February 17, 2006, 3:04pm UTC](https://www.ruby-forum.com/t/ruby-tk-gui-question/69691/1 "2006-02-17T15:04:19Z")

</div>

Hi,

I am writing a Ruby GUI TK application where the top-most portion of the  
screen is a line of static menu buttons. I would like the remaining  
lower  
portion of the screen to be dynamic - as an example, one of the top  
static  
buttons is pressed, in response to that, another window appears in the  
dynamic area where someone can press more buttons, someone presses on of  
those, which then draws a data window, erasing the window which had the  
buttons, then someone closes the data window which brings the user back  
to  
the window which was drawn in response to the button press from the  
static  
button in the top portion of the screen.

Any references to Ruby TK function names would be greatly appreciated.

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:** [February 17, 2006, 5:02pm UTC](https://www.ruby-forum.com/t/ruby-tk-gui-question/69691/2 "2006-02-17T17:02:34Z")

</div>

Hi Harry!

On Fri, 17 Feb 2006, Harry T. wrote:

> Any references to Ruby TK function names would be greatly appreciated.

Disclaimer: I know _squat_ about Ruby-Tk, but against the day that I  
_need_ to know, I’ve kept this link handy:

[http://www.jbrowse.com/text/rubytk\_en.html](http://www.jbrowse.com/text/rubytk_en.html)

Cheers,

---

<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:** [February 17, 2006, 8:50pm UTC](https://www.ruby-forum.com/t/ruby-tk-gui-question/69691/3 "2006-02-17T20:50:33Z")

</div>

Harry T. wrote:

> Hi,
> 
> I am writing a Ruby GUI TK application …
> 
> Any references to Ruby TK function names would be greatly appreciated.

The Tcl/Tk manual is easy to find with google, for example:  
[http://www.tcl.tk/man/tcl8.4/TkCmd/contents.htm](http://www.tcl.tk/man/tcl8.4/TkCmd/contents.htm)

1. Ensure this works:  
require ‘tk’

2. To convert the Tk widget commands to Ruby class names, prepend “Tk”  
and capitalise,  
for example the Tcl/Tk “entry” command becomes the Ruby class  
“TkEntry”

3. To apply an option, just use the tk option name without the leading  
‘-’,  
for example “-relief” is just “relief”.

4. Options can be set in two different ways, either:  
a. provide a hash of option value pairs, the option name is a string:  
example { ‘relief’ =\> ‘ridge’, ‘width’=\>3 }  
and hand this hash over as a parameter (you don’t necessarily  
need { } in a method call), or  
b. provide a block, e.g. to new  
entry = TkEntry.new(root) do  
justify ‘center’  
width 3  
borderwidth 3  
relief ‘ridge’  
end  
# notice the option names are not quoted here, but look like  
method names

The other thing you might want to do is take a look at this Ruby/Tk  
tutorial  
[http://members.chello.nl/~k.vangelder/ruby/learntk/](http://members.chello.nl/~k.vangelder/ruby/learntk/)

I haven’t read this, but it looked interesting:  
[http://www.syngress.com/book\_catalog/183\_Ruby/sample.htm](http://www.syngress.com/book_catalog/183_Ruby/sample.htm)

HTH  
GB-)
