Karger78 has asked for the wisdom of the Perl Monks concerning the following question:

Hello All, I am trying to figure out a way to accomplish this. What I want is when the person places a check mark in the checkbox, two fields become enabled, if the check mark is unchecked, then the two fields become disabled. So I provided a snip of the code below. The text filed called LocalCpPath and the button called btnLocalcpPath, I would like disabled by default, when the end user ticks off the cpLogsLocal checkbox, then the button and text field becomes enabled. I have been toying with the on click envent for the check box without success. I guess my question would be, how change I change the disabled from 1 to 0 with a on click event? Any help would be appreciated.
$main->AddTextfield( -name=> "LocalCpPath", -width =>100, -height =>20, -pos => [95,55], -disabled=>1, ); $main->AddButton( -name=> "btnLocalCpPath", -text=> "...", -width =>30, -height =>20, -pos => [210,55], -disabled=>1, ); $main->AddCheckbox( -name => "cpLogsLocal", -text => "Copy Logs Local", -pos => [210, 5], -size => [100, 21], ); sub cpLogsLocal_Click{ $main->AddTextfield(-LocalCpPath->disabled(0)); ##the about doesn't work, just playing }

Replies are listed 'Best First'.
Re: Win32:GUI check box to enable and disable features
by SuicideJunkie (Vicar) on Sep 01, 2009 at 14:05 UTC

    I'm not sure why but it seems like you're trying to add another text field during what looks like a click event.

    Why not just update the state of the existing widget(s) like you said in the description?
    eg: $widget->configure(-state=>  ('disabled' || 'normal')  );

      Hi, Thanks for your response. here is what I added <code> sub cpLogsLocal_Click{ #$main->AddTextfield(-LocalCpPath->disabled(0)); $main->btnLocalCpPath->configure(-state=> ('disabled' || 'normal') ); } </code It doesn't seem to like the configure method. "Con't find 'configure' in package Win32::GUI."
        I did do some further changes, I think I am on the right track at this time. So I am trying to change a property of textbox called LocalCpPath. Doesn't seem to work though.
        sub cpLogsLocal_Click{ $main->LocalCpPath(-disabled=>0,); }