From: Joe Van Dyk <joevandyk / gmail.com>
Subject: Tkmenubar and checkbuttons
Date: Thu, 5 May 2005 17:10:29 +0900
Message-ID: <c715e64050505011044a55b21 / mail.gmail.com>
> I have this snippet as part of my Tk menu bar spec:
> 
>       ['Options',
>          ['Display Map', proc {show_map()}],
>          ['Hide Map', proc {hide_map()}]
> 
> How can I combine those two menu options into a single checkbutton
> menu option?  The API documentation on it wasn't clear at all.

Maybe, do you want such like as the following?
----------------------------------------------------------
require 'tk'

m = nil  # variable to pass the menu object to procedures

spec = [
  ['Option', 

    # define a command entry by Hash
    {
      :type=>'command', 
      :label=>'Display Map', 
      :command=>proc{
        show_map()
        m.entryconfigure('Display Map', :state=>:disabled)
        m.entryconfigure('Hide Map', :state=>:normal)
      }, 
      :state=>:normal
    }, 

    # define a command entry by Array
    ['Hide Map', 
      proc{
        hide_map()
        m.entryconfigure('Display Map', :state=>:normal)
        m.entryconfigure('Hide Map', :state=>:disabled)
      }, 
      nil, nil, 
      {:state=>:disabled}
    ]
  ]
]

# add menubar and get the cascade menu object
m = Tk.root.add_menubar(spec).entrycget('Option', :menu)

Tk.mainloop
----------------------------------------------------------
-- 
Hidetoshi NAGAI (nagai / ai.kyutech.ac.jp)