OSDN Git Service

ruby-1.9.1-rc1
[splhack/AndroidRuby.git] / lib / ruby-1.9.1-rc1 / ext / tk / sample / tkextlib / iwidgets / sample / entryfield-3.rb
1 #!/usr/bin/env ruby
2 #########################################################
3 #
4 #  set Tk.encoding = 'utf-8' for a utf8 charecter
5 #
6 #########################################################
7 require 'tk'
8 require 'tkextlib/iwidgets'
9
10 Tk.encoding = 'utf-8'
11
12 TkOption.add('*textBackground', 'white')
13
14 ef  = Tk::Iwidgets::Entryfield.new(:command=>proc{puts "Return Pressed"})
15
16 fef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Fixed:', 
17                                    :fixed=>10, :width=>12)
18
19 nef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Numeric:', 
20                                    :validate=>:numeric, :width=>12)
21
22 aef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Alphabetic:', 
23                                    :validate=>:alphabetic, :width=>12, 
24                                    :invalid=>proc{
25                                      puts "Alphabetic contents invalid"
26                                    })
27
28 pef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Password:', :width=>12, 
29                                    :show=>"\267",  ## <=== utf8 character
30                                    :command=>proc{puts "Return Pressed"})
31
32 Tk::Iwidgets::Labeledwidget.alignlabels(ef, fef, nef, aef, pef)
33
34 ef.pack(:fil=>:x,  :expand=>true, :padx=>10, :pady=>5)
35 fef.pack(:fil=>:x,  :expand=>true, :padx=>10, :pady=>5)
36 nef.pack(:fil=>:x,  :expand=>true, :padx=>10, :pady=>5)
37 aef.pack(:fil=>:x,  :expand=>true, :padx=>10, :pady=>5)
38 pef.pack(:fil=>:x,  :expand=>true, :padx=>10, :pady=>5)
39
40 Tk.mainloop