Tk widget: variable or textvariable

In Ruby/Tk, is there an easy way to check whether a widget supports
setting variable or textvariable? respond_to? does not work.

From: “Martin C.” [email protected]
Subject: tk widget: variable or textvariable
Date: Wed, 8 Dec 2010 04:27:22 +0900
Message-ID: [email protected]

In Ruby/Tk, is there an easy way to check whether a widget supports
setting variable or textvariable? respond_to? does not work.

  1. catch RuntimeError on TkWindow#cget or TkWindow#[] or
    TkWindow#configinfo.
    If raised, the widget doesn’t support the option.

  2. check keys of a Hash returned by TkWindow.current_configinfo.
    e.g. TkButton.new.current_configinfo.keys.find{|opt| opt =~
    /variable/}