# Ruby TK

**URL:** <https://www.ruby-forum.com/t/ruby-tk/118363>\
**Category:** Ruby\
**Created:** [October 26, 2007, 4:10am UTC](https://www.ruby-forum.com/t/ruby-tk/118363 "2007-10-26T04:10:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [October 26, 2007, 4:10am UTC](https://www.ruby-forum.com/t/ruby-tk/118363/1 "2007-10-26T04:10:27Z")

</div>

i know im doing alot wrong, but i need all the help i can  
get…so…plz spare the time, thanks

here is what i got —

`
irb
Start up Tk with Ruby
require ‘tk’
root = TkRoot.new {title “Homework #4”}
top = TkFrame.new(root) { relief ‘raised’; border 5 }
TkButton.new(top) do
text “Clear”
command { delete(0,0, end) }
pack(‘side’ => ‘left’, ‘padx’ => 15, ‘pady’ => 15)
end
TkButton.new(top) do
text “Cancel”
command { exit }
pack(‘side’ => ‘left’, ‘padx’ => 15, ‘pady’ => 15)
end
TkText.new(top) do
borderwidth 4
highlightthickness 2
highlightcolor ‘black’
pack(‘side’ => ‘right’, ‘fill’ => ‘both’, ‘expand’ => true)
end
TkLabel.new(top) { text ‘File:’ ; pack(‘padx’ => 15, ‘pady’ => 15) }
@text = TkVariable.new(right) do
TkEntry.new(right, ‘textvariable’ => @text).pack(‘side’ =>
‘bottom’, ‘padx’ => 15, ‘pady’ => 15)
end
top.pack(‘fill’ => ‘both’, ‘side’ => ‘top’)
Tk.mainloop
`

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [October 26, 2007, 8:37pm UTC](https://www.ruby-forum.com/t/ruby-tk/118363/2 "2007-10-26T20:37:48Z")

</div>

Wow… You wern’t jokin’  
Your root definition should look something like this

root = TkRoot.new(‘title’=\>‘Homework#4’)

or you can set the title after the definition like this

root = TkRoot.new()  
root.title(‘Homework#4’)

Just about everything in RubyTk follows the same hash-like pattern.  
This should give you a better start.

Jayson

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [October 26, 2007, 8:47pm UTC](https://www.ruby-forum.com/t/ruby-tk/118363/3 "2007-10-26T20:47:44Z")

</div>

My mistake. I had never seen the attribures in the curley brackets the  
way you have them. Guess I will have to defer my expert opinion to  
someone else.
