1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/ext/tk/sample/demos-en/form.rb
nagai 75362fbd47 * (IMPORTANT BUG FIX) scan of event keywords doesn't work on recent
versions of Tck/Tk
* (bug fix) initialize error of instance variable on TkComposite
* (bug fix) initialize error on encoding-system on MultiTkIp
* (bug fix) trouble on destroying widgets
* (new) add JP and EN version of Ruby/Tk widget demos


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-07-31 20:52:40 +00:00

62 lines
1.4 KiB
Ruby

#
# form widget demo (called by 'widget')
#
# toplevel widget
if defined?($form_demo) && $form_demo
$form_demo.destroy
$form_demo = nil
end
# demo toplevel widget
$form_demo = TkToplevel.new {|w|
title("Form Demonstration")
iconname("form")
positionWindow(w)
}
# label
msg = TkLabel.new($form_demo) {
font $font
wraplength '4i'
justify 'left'
text "This window contains a simple form where you can type in the various entries and use tabs to move circularly between the entries."
}
msg.pack('side'=>'top', 'fill'=>'x')
# frame
TkFrame.new($form_demo) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
tmppath = $form_demo
$form_demo = nil
tmppath.destroy
}
}.pack('side'=>'left', 'expand'=>'yes')
TkButton.new(frame) {
text 'Show Code'
command proc{showCode 'form'}
}.pack('side'=>'left', 'expand'=>'yes')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# entry
form_data = []
(1..5).each{|i|
f = TkFrame.new($form_demo, 'bd'=>2)
e = TkEntry.new(f, 'relief'=>'sunken', 'width'=>40)
l = TkLabel.new(f)
e.pack('side'=>'right')
l.pack('side'=>'left')
form_data[i] = {'frame'=>f, 'entry'=>e, 'label'=>l}
}
#
form_data[1]['label'].text('Name:')
form_data[2]['label'].text('Address:')
form_data[5]['label'].text('Phone:')
# pack
(1..5).each{|i| form_data[i]['frame'].pack('side'=>'top', 'fill'=>'x')}