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
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