example

2 June 2008 Bezoar

I wanted to see how far I could take the A calendar Widget in 20 min here is the result. Hover over today's date for 3 seconds to have the appointment schedule appear. By default the priority prints in the message. I originally had it as the time. A good feature would be to allow the user to change the comparison function for the priority so times could be used. Also -activeforeground option for the days of the month would also be nice; having that would allow more color schemes.

  #!/bin/sh
   # the next line restarts using wish  ( change this to your setup ) \
   exec /opt/usr/bin/tclsh8.5  "$0" ${1+"$@"}
  if { [ catch {package require Tk } err ] != 0 } {
      puts stderr "Unable to find package Tk ... adjust your auto_path!";
  }
  # make sure to save the callib code in a file and source it .
  source ./callib.tcl

  proc setMonthYear { cal } {
      global monthYear
      set p [ $cal configure -month ]
      set y [ $cal configure -year ]
      set scanStr [format "%s/1/%s 12:00:00"  $p $y ]
      set timestamp [ clock scan $scanStr ]
      set monthYear [clock format $timestamp -format "%b -%Y" ]
  }

  proc incrementMonth { cal   } {
      $cal nextmonth
      setMonthYear  $cal
  }
  proc decrementMonth { cal   } {
      $cal prevmonth
      setMonthYear  $cal
  }
  proc incrementYear { cal   } {
      $cal nextyear
      setMonthYear  $cal
  }
  proc decrementYear { cal   } {
      $cal prevyear
      setMonthYear $cal
  }
  set monthDay [clock format [clock seconds ] -format "%b - %Y" ]
  frame .frame -background blue -relief flat
  set topframe [ frame .frame.topframe  -background blue ]
  button .frame.exit -text exit -command { destroy . }
  set calendar [ calwid .frame.calendar -font { helvetica 10 bold } \
      -dayfont {Arial 10 bold } \
  -background blue \
  -foreground white \
  -activebackground cyan \
  -clickedcolor    black \
  -startsunday     0 \
  -delay 3000 \
  -daynames {Su Mo Tu Wed Th Fr Sa} \
      -month [clock format [clock seconds ] -format "%N" ] \
  -year  [clock format [clock seconds ] -format "%Y" ] \
      -relief groove ]
  button $topframe.decyear   -text "<<"  -command " decrementYear $calendar "
  button $topframe.decmonth   -text "<"  -command " decrementMonth $calendar "
  label  $topframe.monthyrlbl  -textvariable monthYear -background blue -foreground white -font {Helvetica 14 bold } -width 10
  button $topframe.incrmonth -text ">" -command " incrementMonth $calendar "
  button $topframe.incryear  -text ">>" -command " incrementYear $calendar "

  pack .frame -side top -expand 1 -fill both
  pack $topframe -side top -expand 1 -fill x -pady 3
  pack $topframe.decyear    -side left -expand 1 -fill none -padx 3 -pady 3
  pack $topframe.decmonth   -side left -expand 1 -padx 3 -pady 3
  pack $topframe.monthyrlbl -side left -expand 1 -padx 3 -pady 3
  pack $topframe.incrmonth  -side left -expand 1 -padx 3 -pady 3
  pack $topframe.incryear   -side left -expand 1 -padx 3 -pady 3
  pack $calendar   -side top -anchor c  -expand 1
  pack .frame.exit -side bottom -anchor c -fill x -pady 3
  setMonthYear $calendar
  $calendar configure -mark [eval list  [clock format [clock seconds ] -format "%e %N %Y 1 red { 8:00 Get Groceries }" ]]
  $calendar configure -mark [eval list  [clock format [clock seconds ] -format "%e %N %Y 2 red {12:00 Pick up Dry Cleaning}" ]]
  $calendar configure -mark [eval list  [clock format [clock seconds ] -format "%e %N %Y 0 red { 7:00 Wake up and water plants.}"]]
  $calendar configure -mark [eval list  [clock format [clock scan "02/23/2009 12:00:00" ] \
                                       -format "%e %N %Y 0 red { 12:00 Get New Car!}"] ]