summaryrefslogtreecommitdiff
path: root/trunk/ext/tk/sample/demos-en/form.rb
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-25 15:02:05 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-25 15:02:05 +0000
commit0dc342de848a642ecce8db697b8fecd83a63e117 (patch)
tree2b7ed4724aff1f86073e4740134bda9c4aac1a39 /trunk/ext/tk/sample/demos-en/form.rb
parentef70cf7138ab8034b5b806f466e4b484b24f0f88 (diff)
added tag v1_9_0_4
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_9_0_4@18845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'trunk/ext/tk/sample/demos-en/form.rb')
-rw-r--r--trunk/ext/tk/sample/demos-en/form.rb64
1 files changed, 64 insertions, 0 deletions
diff --git a/trunk/ext/tk/sample/demos-en/form.rb b/trunk/ext/tk/sample/demos-en/form.rb
new file mode 100644
index 0000000000..3119752b1c
--- /dev/null
+++ b/trunk/ext/tk/sample/demos-en/form.rb
@@ -0,0 +1,64 @@
+#
+# 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)
+}
+
+base_frame = TkFrame.new($form_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+msg = TkLabel.new(base_frame) {
+ 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(base_frame) {|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(base_frame, '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')}
+