NAME

        Tk::EasyGUI.pm


VERSION

0.13


SYNOPSIS

        use Tk::EasyGUI qw(
                column_of_entries
                row_of_buttons
                entries_accept
                entries_rollback
                entries_to_string
        );
        my $mw = Tk::EasyGUI::init('Some Title', \&some_error_msg_sub);


DESCRIPTION

What you have here is a method of banging out quick and dirty Perl/Tk GUIs for use with almost any Perl code that you might have in early development, or for which you may have only temporary need. It does two things for you. Firstly, you can use it to build a simple GUI most quickly. Secondly, the GUI you build will have built-in input-error checking.

A complete, fully POD-ified example of how to employ this module may be found online under the URL below...

http://starling.us/tet/gus_perl/gus_easy_gui_pl/gus_example_easy_gui.txt

...look also for this screenshot...

http://starling.us/tet/gus_perl/gus_easy_gui_pl/gus_example_easy_gui.Win32.png


EXPORTED SUBROUTINES

Building Columns of Label-Entry Widgets

        my $path     = '/ram/bar.csv';    # Example path.
        my $real     = '5.0';             # Example real number.
        my $capitals = 'CAPITAL LETTERS'; # Example string.
        my $int_list = '0, 1, 2, 3, 4';
        my $real_list = '0.9, 1.8, 2.7, 3.6, 4.5';
        my @tk_ent = (
                { show_feedback   => 1,
                  label_width     => 10,
                  entry_width     => 40,
                  frame_relief    => 'sunken',
                  frame_pack_side => 'top',
                  all_or_none     => 0,         # Do not require all entries must pass.
                  auto_rollback   => 0,         # Do not roll back if an entry fails.
                }, # Your attribs. Empty hash or none is okay.
                ['Log File',   'ps',   '/ram/foo.log'],              # Data is a string.
                ['Data File',  'po',   \$path],                      # Data via sref.
                ['Capitals',   's',    \$capitals, '^[A-Z| ]+$'],    # Data via sref.
                ['Integer',    'i',    5, 0, 10],                    # Data is an integer.
                ['Int List',   'i,i',  \$int_list,  -2, 9],          # Data via sref.
                ['Real',       'r',    \$real, -10.0, 10.0, 3],      # Data via sref.
                ['Real List',  'r,r',  "$real_list", -3.3, 11.9, 2], # Data via sref.
        );
        my $wgt_1 = column_of_entries($parent, $lbl, $aref);

Building Rows of Buttons

        my @tk_btn = (
                { label_width     => 10,
                  frame_relief    => 'flat',
                  frame_pack_side => 'top' }, # Optional attribs. Empty hash okay.
                [ 'Start',  sub { print "Start\n" }, # Un-toggled label and toggle-on action.
                  'gray', 'green',                   # Un-toggled and toggled colors.
                  'Stop',   sub { print "Stop\n" }   # Toggled label and toggle-off action.
                ],
                [ 'Run',    sub { print "Run\n" },   # Un-toggled label and toggle-on action.
                  'Pause',  sub { print "Pause\n" }  # Toggled label and toggle-off action.
                ],
                [ 'Submit', sub { submit_entries($wgt_1) },  # Label and action.
                  'gray', 'yellow'                           # In-active and active colors.
                ],
                [ 'Exit',   sub { exit MainLoop },   # Label and action. Default colors.
                ],
        );
        my $wgt_2 = row_of_buttons( $mw, 'Actions', \@tk_btn );

Accepting Entries

        entries_accept($wgt);

Rolling Back Entry Widgets

You can roll back (or up, depending on viewpoint) the entry widgets of a given entry widget set. If you don't specify a color, the Entry widgets will be turn yellow, since rollback is ordinarily presumed an error.

        entries_rollback($wgt_1, $wgt_1->{to}, $wgt_1->{fm}, 'white');

Stringifying Entry Widgets

You can get a string of Labels and Entries to be used, for instance, in writing to a log file. The last arg is optional, a regex for those Labels to be excluded.

        entries_to_string($wgt_1, $wgt_1->{to}, 'Log File');


TO DO

Add more widget types.


BUGS AND LIMITATIONS

Only creates columns of label-entry and rows of button widgets at present.


AUTHOR

Gan Uesli Starling <gan@starling.us>


LICENSE AND COPYRIGHT

Copyright (c) 2007 by Gan Uesli Starling. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.