From: Cristian Achim <cristiach / yahoo.com>
Subject: ruby tkentry tkvariable with class wrappers problem
Date: Tue, 24 Mar 2009 04:43:01 +0900
Message-ID: <34100fb324f5193a1b8567f60a34eea0 / ruby-forum.com>
> it doesn't work : it says that themember variable supposed to hold a
> link to the tkVariable object is nil:nilClass when i try to call the
> value member function

Hmmm... 
You may be misunderstanding about a block given to <widgetclass>.new.
# And, your code has a problem about accessing a TkVariable object. 

---------------------------------------------------
   @files_lcoation_text=TkVariable.new
   @files_location_text=""
   @files_location_entry=TkEntry.new(tk_root){
     textvariable @files_location_text
   }.grid("row"=>0 , "column"=>1)
   @files_location_text="tada"
---------------------------------------------------

Such block is evaluated with "instance_eval". 
That is, at internal of the block, "self" is the widget created by 
"new" method. So, @files_location_text in the block is a instance 
variable of the entry widget. 

There are two ways to avoid this problem. 
The one is to use a local variable. 
And another is to use a Hash argument. 

-----<case.1>----------------------------------------------
   @files_lcoation_text = txt_var = TkVariable.new("")
   @files_location_entry=TkEntry.new(tk_root){
     textvariable txt_var
   }.grid("row"=>0 , "column"=>1)
   @files_location_text.value = "tada"
-----------------------------------------------------------

-----<case.2>----------------------------------------------
   @files_lcoation_text = TkVariable.new("")
   @files_location_entry=TkEntry.new(tk_root, :textvariable=>@files_lcoation_text).grid(:row=>0 , :column=>1)
   @files_location_text.value = "tada"
-----------------------------------------------------------

Please take attention to a scope of a variable. 
-- 
Hidetoshi NAGAI (nagai / ai.kyutech.ac.jp)