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/tkextlib/tcllib/datefield.rb
nagai 3514110b89 * ext/tk/lib/tk/*: untabify
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-11 04:51:21 +00:00

29 lines
658 B
Ruby

#!/usr/bin/ruby
require 'tk'
require 'tkextlib/tcllib/datefield'
require 'parsedate'
Tk.root.title('Datefield example')
my_date1 = TkVariable.new
my_date2 = TkVariable.new
my_date1.trace('w'){
begin
t = Time.local(*(ParseDate.parsedate(my_date1.value)))
my_date2.value = t.strftime('%A')
rescue
# ignore error
end
}
df = Tk::Tcllib::Datefield.new(:textvariable=>my_date1)
Tk.grid(TkLabel.new(:text=>'Enter a date:', :anchor=>:e), df, :sticky=>:ew)
Tk.grid(TkLabel.new(:text=>'That date ia a:', :anchor=>:e),
TkLabel.new(:textvariable=>my_date2, :relief=>:sunken, :width=>12),
:sticky=>:ew)
df.set_focus
Tk.mainloop