def command(cmd = Proc.new) @command = cmd
end
end
TkLabel.new(:text=><<EOT).pack
This is a sample of ‘event binding’.
The first button is a normal button widget.
And the second one is a normal label widget
but with some bindings like a button widget.
EOT
This seems to be about binding and re-binding the callbacks on a widget.
What I want to do is actually remove widgets and add new widget to some
containing frame.
I intend to show that a callback for a widget can control another
widget. In other words, you can pack/unpack some widgets in a
callback procedure. If you hate the frame size is changed when packing
some widgets in the frame, you must set TkPack.propagate to false.
Please see the following sample script, and compare the difference
of propagate mode (true/false).
#!/usr/bin/env ruby
require ‘tk’
TkLabel.new(:text=>“Please click the bottom frame”).pack
f = TkFrame.new(:width=>400, :height=>100, :background=>‘yellow’,
:relief=>‘ridge’, :borderwidth=>5).pack
I intend to show that a callback for a widget can control another
widget. In other words, you can pack/unpack some widgets in a
callback procedure. If you hate the frame size is changed when packing
some widgets in the frame, you must set TkPack.propagate to false.
Please see the following sample script, and compare the difference
of propagate mode (true/false).
#!/usr/bin/env ruby
require ‘tk’
TkLabel.new(:text=>“Please click the bottom frame”).pack
f = TkFrame.new(:width=>400, :height=>100, :background=>‘yellow’,
:relief=>‘ridge’, :borderwidth=>5).pack