require 'tk'

root = TkRoot.new() { title "Radiobutton demo" }
top = TkFrame.new(root)
PackOpts  = { "side" => "top", "anchor" => "w" }

major = TkVariable.new

b1 = TkRadioButton.new(top) do
  variable major
  text "Computer science"
  value 1
  command { puts "Major = #{major.value}" }
  pack PackOpts
end

b2 = TkRadioButton.new(top) do
  variable major
  text "Music"
  value 2
  command { puts "Major = #{major.value}" }
  pack PackOpts
end

b3 = TkRadioButton.new(top) do
  variable major
  text "Literature"
  value 3
  command { puts "Major = #{major.value}" }
  pack PackOpts
end

top.pack PackOpts
Tk.mainloop

