in reply to Binding Events In Perl TK

I don't quite understand why you would want to turn the Entry associated with the radiobutton black. This would obscure the text. Are you trying to disable it after it has been selected once? For that matter, I don't see an Entry associated with the radiobuttons in your code.(Or else I'm not running your code right). I see Labels next to radiobuttions. To do what you want, without writing the code for you, is to use the -command option for radiobutton which, which will call a subroutine when the radiobutton is selected. In that sub, you can configure the -background of your entries. Something like:
my $rb1 = $mw->Radiobutton(-text => "Button One", -value => 'button1', -variable => \$rb, -command => [ \&blacken, '$entry1'])->pack +; my $rb2 = $mw->Radiobutton(-text => "Button Two", -value => 'button2', -variable => \$rb, -command => [ \&blacken, '$entry2'])->pack +; sub blacken { my $entry = shift; $entry->configure(-backround => 'black'); #maybe you want #$entry->configure(-state => 'disabled') }
Of course you can get fancy in your blacken sub, and test for the state of the radiobutton, and unblacken if it is blackened already. But I'm clueless as to why you want to do this? If you could be more specific, as to what your desired intent is, we can help more.

I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Re^2: Binding Events In Perl TK
by qumsieh (Scribe) on Aug 27, 2004 at 22:30 UTC
        -command => [ \&blacken, '$entry1']

    That of course won't work since you pass the string literal '$entry1' which you attempt to use as a Tk::Entry object in the blacken() sub.

    You need to remove the quotes.