Calendar [incr Widget]

Makes a nice little calendar window. It opnens showing November,
2006. Clicking on any date results in the date being printed to stdout.

#! /usr/bin/ruby -w # Author: Morton G. # # Date: August 31, 2006 # # Instant Calendar

require ‘tk’
require ‘tkextlib/iwidgets’

DEBUG = []

begin
root = TkRoot.new {title ‘Ruby/Tk Calendar’}

cal = Tk::Iwidgets::Calendar.new(root) {
   outline 'black'
   weekdaybackground 'gray90'
   weekendbackground 'white'
   command {p cal.get}
}
cal.pack('pady'=>10)
cal.show('11/1/2006')

# Set initial window geometry; i.e., size and placement.
win_w, win_h = 250, 195
# root.minsize(win_w, win_h)
win_lf = (root.winfo_screenwidth - win_w) / 2
root.geometry("#{win_w}x#{win_h}+#{win_lf}+50")

# Set resize permissions.
root.resizable(false, false)

# Make Cmnd+Q work as expected.
root.bind('Command-q') {Tk.root.destroy}

Tk.mainloop

ensure
puts DEBUG unless DEBUG.empty?
end

Regards, Morton