# work1001.rb
require 'tk'

t1 = TkText.new

x = TkVariable.new
buffer = TkVariable.new

t2 = TkEntry.new(nil,
    'text'=>'message',
    'textvariable'=>x
)

t3 = TkButton.new(nil,
    'text'=>'Enter',
    'command'=>proc{
        t1.insert('end', x.value + "\n")
	buffer.value += x.value + "\n"
    }
)

t4 = TkButton.new(nil,
    'text'=>'Quit',
    'command'=>proc{
        exit
    }
)

t5 = TkButton.new(nil,
    'text'=>'Save',
    'command'=>proc{
        fp = File::open(x.value,'w')
	fp.print(buffer)
	fp.close
    }
)

t1.pack('side'=>'top')
t2.pack('side'=>'left')
t3.pack('side'=>'left')
t4.pack('side'=>'left')
t5.pack('side'=>'left')

Tk.mainloop