From: Ferenc Engard Date: 2002-08-25T05:40:44+09:00 Subject: interactive ruby/tk app (was: ruby/tk internals) Hello, I am trying to achieve the same thing what is the default in tck/tk: I start the application, and afterwards I can execute statements, changing the user interface, creating new objects. My first thought was the following: ------------------------------------------ evalFrame=TkFrame.new { pack } evalBox=TkText.new(evalFrame) { height 10 pack('fill'=>'x') } evalBtn=TkButton.new(evalFrame) { text "Execute" command proc {evalText(evalBox.value)} pack() } def evalText(text) puts eval text end ------------------------------------------ The problem is, if I create a new Tk object runtime (a TkButton, for example), I cannot store it into a local variable, as I will not be able to reference that (was-local) variable. While I was writing this mail, it came to my mind that I can pass a Binding object to eval(). So, the solution is: ------------------------------------------ $topContext=binding() .... def evalText(text) puts eval text, $topContext end ------------------------------------------ It looks better. Are there other (more pretty :) solutions? Bye: Circum