tk fails to work with TkVariable

S

Stefan Achatz

Hello,
i have here some compressed code from my would-be-application that doesn't
work and i don't know why.
How it should work:
I click the "Open Window"-Button -> a new window opens
I click the "Test"-Button -> a warning-window should open but doesn't
If i remove line 10(TkVariable initialization) everything works well.
What's wrong with initialization of the TkVariable at this point?
Hope someone could help me and thanks in advance
Stefan Achatz

Heres the code:
=== snip
#!/usr/bin/env ruby

require 'tk'

class MyWindow < TkToplevel

def initialize
super

@value = TkVariable.new

this_button = TkButton.new(self) {
text 'Test'
pack('side' => 'left')
}
this_button.command { TkWarning.new("Can you read this?") }

end
end

root = TkRoot.new

root_button = TkButton.new(root) {
text 'Open Window'
pack('side' => 'left')
}
root_button.command { MyWindow.new }

Tk.mainloop
=== snap

And that's the backtrace:
=== snip
---< backtrace of Ruby side >-----
/usr/local/lib/ruby/1.8/tk.rb:1944:in `__eval'
/usr/local/lib/ruby/1.8/tk.rb:1944:in `_eval'
/usr/local/lib/ruby/1.8/tk.rb:1468:in `_ip_eval_core'
/usr/local/lib/ruby/1.8/tk.rb:1482:in `ip_eval'
/usr/local/lib/ruby/1.8/tk/dialog.rb:179:in `show'
/usr/local/lib/ruby/1.8/tk/dialog.rb:282:in `show'
/usr/local/lib/ruby/1.8/tk/dialog.rb:311:in `initialize'
../erazorworks.rb:16:in `new'
../erazorworks.rb:16:in `initialize'
../erazorworks.rb:16:in `call'
/usr/local/lib/ruby/1.8/tk.rb:1089:in `eval_cmd'
/usr/local/lib/ruby/1.8/tk.rb:1089:in `cb_eval'
/usr/local/lib/ruby/1.8/tk.rb:1040:in `call'
/usr/local/lib/ruby/1.8/tk.rb:1178:in `callback'
/usr/local/lib/ruby/1.8/tk.rb:1383:in `mainloop'
/usr/local/lib/ruby/1.8/tk.rb:1383:in `mainloop'
../erazorworks.rb:29
---< backtrace of Tk side >-------
invoked from within
"rb_out c00002"
invoked from within
".w00001.w00002 invoke"
("uplevel" body line 1)
invoked from within
"uplevel #0 [list $w invoke]"
(procedure "tk::ButtonUp" line 22)
invoked from within
"tk::ButtonUp .w00001.w00002"
(command bound to event)
=== snap
 
H

Hidetoshi NAGAI

Hi,

From: Stefan Achatz <[email protected]>
Subject: tk fails to work with TkVariable
Date: Sat, 2 Apr 2005 05:14:43 +0900
Message-ID: said:
i have here some compressed code from my would-be-application that doesn't
work and i don't know why.

Thank you for your report.
That is a Tcl namespace trouble when autoloading 'tk/variable.rb'.
I'll fix it later on CVS.
If you want a quick hack, please add "require 'tk/variable.rb'"
just after "require 'tk'".
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,187
Members
46,730
Latest member
AudryNolan

Latest Threads

Top