|
NAMEUI::Dialog::Screen::Druid - wrapper to screen dialogs.SYNOPSISuse UI::Dialog::Screen::Druid; # $d is an existing instance of UI::Dialog my $druid = new UI::Dialog::Screen::Druid ( dialog => $d ); $druid->add_yesno_step('somename',"Ask the user a y/n question?"); $druid->add_input_step ( 'anothertag',"Tell me something:", "Hello World: {{somename}}" ); my (%answers) = $druid->perform(); if ($answers{aborted}) { die "user canceled at step: ".$answers{key}."\n"; } # %answers contains all the responses, keyed by the first argument # used in the add_*_step() methods. print $answers{anothertag}."\n"; ABSTRACTUI::Dialog::Screen::Druid is a helper class which enables a clean and modular code flow for menu driven applications using UI::Dialog. Using a simple "question" format, tucked into a queue; developers can ask a series of questions and receive back a HASH (or HASHREF) of all the user input keyed by the first argument to the add_*_step() methods.DESCRIPTIONUI::Dialog::Screen::Druid is actually "external" to the UI::Dialog core usage. The class simply wraps around an existing UI::Dialog instance for rendering a druid-walkthrough series of dialogs.Using this class, you define one (or more) druid instances and assign tags and helpful text to questions. Once defined, simply call perform() and receive the resulting HASH (or HASHREF). If the user aborts (presses <ESC>) the druid performance, a simple hash containing two key/value pairs is returned and resembles the following: { aborted => 1, key => "tagNameOfAbortedStep" } EXPORTNone
INHERITSNone
CONSTRUCTORnew( %options )
# Have UI::Dialog::Screen::Druid use an existing UI::Dialog instance # to render the user interface. my $druid = new( dialog => $d ); # Also accepts UI::Dialog constructor arguments, so that it can create # it's own instance of UI::Dialog if none is provided. my $druid = new( title => 'Default Title', backtitle => 'Backtitle', width => 65, height => 20, listheight => 5, order => [ 'zenity', 'xdialog', 'gdialog' ] );
This is the Class Constructor method. It accepts a list
of key => value pairs and uses them as the defaults when interacting with
the various widgets.
A blessed object reference of the
UI::Dialog::Screen::Druid class.
DRUID METHODSadd_yesno_step( )
$druid->add_yesno_step( "yesnotag", "Yes/no question?" );
Append a new yesno() dialog step to
the druid performance, keyed by the first argument.
Nothing
add_input_step( )
$druid->add_input_step( "inputtag", "Helpful text", "default text" );
Append a new inputbox() dialog step
to the druid performance, keyed by the first argument.
A unique property to this druid step in particular is that the default text (the third arguement) goes through a semi-templating system. By using {{keytag}} within the default text string, when the input question is posed to the user, the {{keytag}} string is replaced with the user's response to a prior question keyed as keytag. For example: $druid->add_input_step ( "user_name", "Tell me the user name you'd like.", "$ENV{USER}" ); $druid->add_input_step ( "another_q", "What is the email address you'd like?", "{{user_name}}@example.com" ); When the above is performed, assuming the user entered "boring" for the user_name question; the suggested (default) email address would become boring@example.com.
Nothing
add_password_step( )
$druid->add_password_step( "passwordtag", "Helpful text." );
Append a new password() dialog step
to the druid performance, keyed by the first argument.
Nothing
add_menu_step( )
$druid->add_menu_step( "menutag", "Helpful text", [qw|item0 item1|] );
Append a new menu() dialog step to
the druid performance, keyed by the first argument.
The third argument is an ARRAYREF containing the options the user can select from. This is not the same as the menu() method's list argument. Whatever is supplied is what is returned as the response for the keyed question. In the above EXAMPLE the user would be presented with two options in a menu; "item0" and "item1". Upon selecting one of those two options; the %answers HASH would contain menutag = "item0"> (if the user selected "item0" of course).
Nothing
SEE ALSO
BUGSPlease email the author with any bug reports. Include the name of the module in the subject line.AUTHORKevin C. Krinke, <kevin@krinke.ca>COPYRIGHT AND LICENSECopyright (C) 2004-2016 Kevin C. Krinke <kevin@krinke.ca> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Visit the GSP FreeBSD Man Page Interface. |