Skip to content

Instantly share code, notes, and snippets.

@nuke99
Created May 28, 2012 21:55
Show Gist options
  • Save nuke99/2821356 to your computer and use it in GitHub Desktop.
Save nuke99/2821356 to your computer and use it in GitHub Desktop.
require 'tk'
class Actions
def self.input(fname,sname)
return "Your Name is #{fname} #{sname}"
end
end
panel = TkRoot.new{title "First Ruby App"}
mainframe = TkFrame.new(panel){
relief 'sunken'
borderwidth 3
background "#808080"
height 200
width 600
padx 5
pady 3
pack('side' => 'left')
}
lbl_fname = TkLabel.new(mainframe){
text "Enter First Name :"
background "#808080"
padx 5
pady 2
pack('side'=>'left')
}
lbl_sname = TkLabel.new(mainframe){
text "Enter Second Name :"
background "#808080"
padx 5
pady 2
pack('side'=>'left')
}
lbl_output = TkLabel.new(mainframe){
text
background "#808080"
padx 5
pady 2
}
txt_fname = TkEntry.new(mainframe){
background "#F8F8F8"
pack('side'=>'left')
}
txt_sname = TkEntry.new(mainframe){
background "#F8F8F8"
pack('side'=>'left')
}
btn_value = TkButton.new(mainframe){
text "Say it !"
background "#D8D8D8"
activebackground "#B0B0B0"
height 1
width 5
command (
proc {lbl_output['text'] = Actions.input(txt_fname.value,txt_sname.value)}
)
}
lbl_fname.place('x'=>10,
'y'=>20)
lbl_sname.place('x'=>10,
'y'=>40)
lbl_output.place('x'=>30,
'y'=>100)
txt_fname.place('x'=>150,
'y'=>20)
txt_sname.place('x'=>150,
'y'=>40)
btn_value.place('x'=>250,'y'=>70)
Tk.mainloop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment