[Ruby/Tk example] Calendar [incr Widget]

Discussion in 'Ruby' started by Morton Goldberg, Sep 5, 2006.

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

    <code>
    #! /usr/bin/ruby -w
    # Author: Morton Goldberg
    #
    # 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
    </code>

    Regards, Morton
    Morton Goldberg, Sep 5, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. again some incr/decrement question

    , Jul 2, 2005, in forum: C Programming
    Replies:
    1
    Views:
    280
    Denis Kasak
    Jul 2, 2005
  2. William Pursell

    incr MACRO

    William Pursell, Feb 26, 2008, in forum: C Programming
    Replies:
    11
    Views:
    614
    Chris Thomasson
    Feb 27, 2008
  3. Morton Goldberg

    Using [incr Widgets] in Ruby/Tk on OS X

    Morton Goldberg, Sep 1, 2006, in forum: Ruby
    Replies:
    5
    Views:
    201
    Hidetoshi NAGAI
    Sep 1, 2006
  4. Morton Goldberg
    Replies:
    0
    Views:
    102
    Morton Goldberg
    Sep 6, 2006
  5. Morton Goldberg

    [Ruby/Tk example] Feedback [incr Widget]

    Morton Goldberg, Sep 5, 2006, in forum: Ruby
    Replies:
    0
    Views:
    130
    Morton Goldberg
    Sep 5, 2006
Loading...

Share This Page