DOKK / manpages / debian 12 / libui-dialog-perl / UI::Dialog::Screen::Druid.3pm.en
UI::Dialog::Screen::Druid(3pm) User Contributed Perl Documentation UI::Dialog::Screen::Druid(3pm)

UI::Dialog::Screen::Druid - wrapper to screen dialogs.

  use 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";

UI::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.

UI::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" }

None

None

 # 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' ] );
DESCRIPTION
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.
The (...)'s after each option indicate the default for the option. An * denotes support by all the widget methods on a per-use policy defaulting to the values decided during object creation.

 $druid->add_yesno_step( "yesnotag", "Yes/no question?" );
DESCRIPTION
Append a new yesno() dialog step to the druid performance, keyed by the first argument.
Nothing

 $druid->add_input_step( "inputtag", "Helpful text", "default text" );
DESCRIPTION
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

 $druid->add_password_step( "passwordtag", "Helpful text." );
DESCRIPTION
Append a new password() dialog step to the druid performance, keyed by the first argument.
Nothing

 $druid->add_menu_step( "menutag", "Helpful text", [qw|item0 item1|] );
DESCRIPTION
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

 UI::Dialog
 UI::Dialog::GNOME
 UI::Dialog::KDE
 UI::Dialog::Console
 UI::Dialog::Screen::Menu
 UI::Dialog::Backend
 UI::Dialog::Backend::ASCII
 UI::Dialog::Backend::CDialog
 UI::Dialog::Backend::GDialog
 UI::Dialog::Backend::KDialog
 UI::Dialog::Backend::Nautilus
 UI::Dialog::Backend::Whiptail
 UI::Dialog::Backend::XDialog
 UI::Dialog::Backend::XOSD
 UI::Dialog::Backend::Zenity
    
 dialog(1), whiptail(1), zenity(1), gdialog(1), Xdialog(1),
 osd_cat(1), kdialog(1) and nautilus(1)
    

Please email the author with any bug reports. Include the name of the module in the subject line.

Kevin C. Krinke, <kevin@krinke.ca>

 Copyright (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
2018-10-27 perl v5.26.2