UI::Di...::Druid(3pm)

πŸ“¦
version 1.21 Β· 3 versions
, in ubuntu jammy, ubuntu noble

πŸ’– UI::Dialog::Screen::Druid β€” the UI::Di...::Druid(3pm) page, but make it cute πŸ’–

okay bestie, sit down, hydrate, because we're about to make screen dialogs make sense. this is the manual for UI::Dialog::Screen::Druid, a lil wrapper class for screen dialogs, and yes it's giving very much "modular code flow" energy. 🧚


✨ NAME ✨

UI::Dialog::Screen::Druid β€” literally just a wrapper to screen dialogs. that's it. that's the name. πŸ’…


🌸 SYNOPSIS 🌸

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

ok so you make a druid, you queue up your lil questions, you perform() and boom β€” you get all the answers back in a hash. it's giving organized. it's giving efficient. ✨


πŸ¦‹ ABSTRACT πŸ¦‹

UI::Dialog::Screen::Druid is a helper class that enables a clean and modular code flow for menu driven applications using UI::Dialog. you use a simple "question" format, tuck it into a queue, and then developers can ask a whole series of questions and get back a HASH (or HASHREF) of all the user input, keyed by the first argument to the add_*_step() methods. no cap, that's the whole vibe. πŸŽ€


πŸ’œ DESCRIPTION πŸ’œ

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. it's the sidekick. the bestie. the hype woman. 🫢

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). iconic behavior honestly.

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

so like, if they bail, you still know where they bailed. thoughtful. πŸ’…


🌈 EXPORT 🌈

  None

nothing. zero. nada. it exports nothing, and honestly? respect. boundaries. ✨


⭐ INHERITS ⭐

  None

also nothing! it inherits from no one. it's self-made. main character energy fr fr. πŸ‘‘


πŸŽ€ CONSTRUCTOR πŸŽ€

new( %options )

πŸ’– EXAMPLE πŸ’–

     # 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.

πŸ¦‹ RETURNS πŸ¦‹

A blessed object reference of the UI::Dialog::Screen::Druid class.

✨ OPTIONS ✨

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.

  • dialog = UI::Dialog β€” default is undef
  • debug = 0,1,2 β€” default is 0
  • order = [ zenity, xdialog, gdialog, kdialog, cdialog, whiptail, ascii ] β€” default is as indicated
  • PATH = [ /bin, /usr/bin, /usr/local/bin, /opt/bin ] β€” default is as indicated
  • backtitle = "backtitle" β€” default is '' *
  • title = "title" β€” default is '' *
  • beepbefore = 0,1 β€” default is 0 *
  • beepafter = 0,1 β€” default is 0 *
  • height = \d+ β€” default is 20 *
  • width = \d+ β€” default is 65 *
  • listheight = \d+ β€” default is 5 *

πŸ‘‘ DRUID METHODS πŸ‘‘

add_yesno_step( )

πŸ’– EXAMPLE πŸ’–

     $druid->add_yesno_step( "yesnotag", "Yes/no question?" );

🌸 DESCRIPTION 🌸

Append a new yesno() dialog step to the druid performance, keyed by the first argument.

πŸ¦‹ RETURNS πŸ¦‹

Nothing


add_input_step( )

πŸ’– EXAMPLE πŸ’–

     $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.

ok that's actually so smart β€” the templating eats. πŸ”₯

πŸ¦‹ RETURNS πŸ¦‹

Nothing


add_password_step( )

πŸ’– EXAMPLE πŸ’–

     $druid->add_password_step( "passwordtag", "Helpful text." );

🌸 DESCRIPTION 🌸

Append a new password() dialog step to the druid performance, keyed by the first argument.

πŸ¦‹ RETURNS πŸ¦‹

Nothing


add_menu_step( )

πŸ’– EXAMPLE πŸ’–

     $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).

πŸ¦‹ RETURNS πŸ¦‹

Nothing


🌈 SEE ALSO 🌈

PERLDOC

  • 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

MAN FILES

dialog(1), whiptail(1), zenity(1), gdialog(1), Xdialog(1), osd_cat(1), kdialog(1) and nautilus(1)


πŸ’€ BUGS πŸ’€

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

bestie if you find a bug, don't just suffer in silence β€” email the author and put the module name in the subject line. that's the whole assignment. πŸ™ˆ

🫢 AUTHOR 🫢

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

and that's the whole page, bestie!! πŸŽ€ this one's perl v5.28.0, dated 2018-10-27, and it lives in the UI::Di...::Druid(3pm) slot. go forth and build your druid walkthroughs. slay. βœ¨πŸ’…πŸ¦‹

πŸ“¦ where this page comes from