Ruby TK

W

wiz_pendases

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 ---

<code>
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
</code>
 
J

Jayson Williams

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
 
J

Jayson Williams

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.
 

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

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top