Skip to content

Items handy_tk_utilities

ggodart edited this page Jan 2, 2021 · 4 revisions

handy_tk_utilities

See original

SYNOPSIS

None

DESCRIPTION

None

INHERITS

none

INI PARAMETERS

None

METHODS

Method Description
tk_button
tk_mbutton
Use these functions to add a Tk button widget to the MisterHouse tk grid (tk_button) or the tk menu_bar (tk_mbutton). &tk_button will accept multiple variables, displaying them in a row in the grid.
Usage:
&tk_mbutton('Button Name', \&subroutine);<br/&tk_button('Button1', \&sub1);
&tk_button('Button1', \&sub1, 'Button2', \&sub2,'Button3', \&sub3);
Examples:
&tk_mbutton('Help', \&help);
&tk_button('Reload(F1)', \&read_code, 'Pause (F2)', \&pause,
' Exit (F3) ', \&sig_handler, 'Debug(F4)', \&toggle_debug,
'Log(F5)', \&toggle_log);
tk_checkbutton tAdds a Tk checkbutton widget to the MisterHouse tk grid. It will accept multiple variables, displaying them in a row in the grid.
Usage:
&tk_checkbutton('text', \&var1);`` &tk_checkbutton('test1', \&var1, 'text22', \&var22, 'text3', \&var33);
Examples:
&tk_checkbutton('Debug on', \$config_parms{debug});
&tk_checkbutton('Sleeping Parents', \$Save{sleeping_parents},
'Sleeping Kids', \$Save{sleeping_kids});
tk_entry Use this function to allow for arbitrary data to be entered via the MisterHousetk grid.
Usage:
&tk_entry('Entry label:', $state_based_object);
&tk_entry('Entry label:', \$variable);
&tk_entry('Entry label:', \$variable, 'Entry label2:, \$variable2);
Example:
&tk_entry('Sleep time:', \$Loop_Sleep_Time);
&tk_entry('Test in 1', \$Save{test_input1}, 'Test in 2', \$Save{test_input2});
Note: The $variable reflects the data, as it is being entered. If you want to test on the data only after the RETURN key has been hit, use %Tk_results array. The $variable is copied to $Tk_results{'Entry label:'} only after the RETURN key has been entered.
Now you can now also use a state based object (like Generic_Item) to store/monitor/change the tk_entry text.
Examples:
&tk_entry('TV search',$Save{tv_search});<br/> if ($state = $Tk_results{'TV search'}) {<br/> run qq[get_tv_info -times all -keys "$state"];<br/> set_watch $f_tv_file;<br/> undef $Tk_results{'TV search'};<br/> }<br/><br/> $mp3_search_text = new Generic_Item;<br/> $mp3_search_text -> tie_event('print_log "mp3 search text is now $state"');<br/> &tk_entry('mp3 Search', $mp3_search_text);`
tk_label
tk_mlabel
Use these functions to add a Tk label widget to the MisterHouse tk grid (tk_label) or the tk menu_bar (tk_mlabel). To avoid duplicate labels after a reload, pass a label name as a 2nd parm.
Usage:
&tk_mlabel(\$variable, $label);
Example:
&tk_mlabel(\$Save{email_flag}, 'email flag');
tk_radiobutton Use this function to create radio buttons in the MisterHouse tk grid. If labels are not specified, the values are displayed.
Usage:
&tk_radiobutton('Button label:', $state_based_object, ['value1', 'value2', 'value3']);
&tk_radiobutton('Button label:', \$variable, ['value1', 'value2', 'value3']);
&tk_radiobutton('Button label:', \$variable, ['value1', 'value2', 'value3'],
['label1', 'label2', 'label3']);
Examples: &tk_radiobutton('Mode', \$Save{mode}, ['normal', 'mute', 'offline']);
&tk_radiobutton('Debug', \$config_parms{debug}, [1, 0], ['On', 'Off']);
&tk_radiobutton('Tracking', \$config_parms{tracking_speakflag}, [0,1,2,3],
['None', 'GPS', 'WX', 'All']);
my $alarm_states = "Disarmed,Disarming,Arming,Armed,Violated,Exit Delay,Entry Delay";
my @alarm_states = split ',', $alarm_states;
$alarm_status = new Generic_Item;
&tk_radiobutton('Security Status', $alarm_status, [@alarm_states]);

$v_alarm_status = new Voice_Cmd "Set the alarm to [$alarm_states]";
$v_alarm_status -> tie_items($alarm_status);
print_log "Alarm status changed to $state" if $state = state_now $alarm_status;

See mh/code/examples/tk_examples.pl for more tk_* examples.

AUTHOR

SEE ALSO

Clone this wiki locally