Curses-UI
view release on metacpan or search on metacpan
examples/demo-widgets view on Meta::CPAN
$w{5}->add(
undef, 'Listbox',
-y => 8,
-padbottom => 2,
-values => $values,
-labels => $labels,
-width => 20,
-border => 1,
-title => 'Listbox',
-vscrollbar => 1,
-onchange => \&listbox_callback,
);
$w{5}->add(
undef, 'Listbox',
-y => 8,
-padbottom => 2,
-x => 21,
-values => $values,
-labels => $labels,
-width => 20,
-border => 1,
-multi => 1,
-title => 'Multi-select',
-vscrollbar => 1,
-onchange => \&listbox_callback,
);
$w{5}->add(
undef, 'Radiobuttonbox',
-y => 8,
-padbottom => 2,
-x => 42,
-values => $values,
-labels => $labels,
-width => 20,
-border => 1,
-title => 'Radiobuttonbox',
-vscrollbar => 1,
-onchange => \&listbox_callback,
);
$w{5}->add(
'listboxlabel', 'Label',
-y => -1,
-bold => 1,
-text => "Select any option in one of the listboxes please....",
-width => -1,
);
# ----------------------------------------------------------------------
# Popupmenu
# ----------------------------------------------------------------------
$w{6}->add(
undef, 'Label',
-text => "The popmenu is much like a standard listbox. The difference is\n"
. "that only the currently selected value is visible (or ---- if\n"
. "no value is yet selected). The list of possible values will be\n"
. "shown as a separate popup windows if requested.\n"
. "Press <ENTER> or <CURSOR-RIGHT> to open the popupbox and use\n"
. "those same keys to select a value (or use <CURSOR-LEFT> to close\n"
. "the popup listbox without selecting a value from it). Press\n"
. "</> in the popup for a 'less'-like search through the list."
);
$w{6}->add(
undef, 'Popupmenu',
-y => 9,
-values => $values,
-labels => $labels,
-width => 20,
-onchange => sub {
my $pm = shift;
my $lbl = $pm->parent->getobj('popupmenulabel');
my $val = $pm->get;
$val = "<undef>" unless defined $val;
my $lab = $pm->{-labels}->{$val};
$val .= " (label = '$lab')" if defined $lab;
$lbl->text($val);
$lbl->draw;
},
);
$w{6}->add(
undef, 'Label', -y => 9, -x => 21,
-text => "--- selected --->"
);
$w{6}->add(
'popupmenulabel', 'Label',
-y => 9, -x => 39, -width => -1,
-bold => 1,
-text => "none"
);
# ----------------------------------------------------------------------
# Progressbar
# ----------------------------------------------------------------------
$w{7}->add(
'progressbarlabel', 'Label',
-x => -1, -y => 3, -width => 10, -border => 1,
-text => "the time"
);
$w{7}->add(
undef, 'Label',
-text => "The progressbar can be used to provide some progress information\n"
. "to the user of a program. Progressbars can be drawn in several\n"
. "ways (see below for a couple of examples). In this example, I\n"
. "just built a kind of clock (the values for the bars are \n"
. "depending upon the current time)."
);
$w{7}->add( undef, "Label", -y => 7, -text => "Showing value");
$w{7}->add( 'p1', 'Progressbar', -max => 24,
-x => 15, -y => 6, -showvalue => 1 );
$w{7}->add( undef, "Label", -y => 10, -text => "No centerline");
$w{7}->add( 'p2', 'Progressbar', -max => 60,
-x => 15, -y => 9, -nocenterline => 1 );
$w{7}->add( undef, "Label", -y => 13, -text => "No percentage");
$w{7}->add( 'p3', 'Progressbar', -max => 60,
-x => 15, -y => 12, -nopercentage => 1 );
sub progressbar_timer_callback($;)
{
my $cui = shift;
my @l = localtime;
$w{7}->getobj('p1')->pos($l[2]);
$w{7}->getobj('p2')->pos($l[1]);
$w{7}->getobj('p3')->pos($l[0]);
$w{7}->getobj('progressbarlabel')->text(
sprintf("%02d:%02d:%02d", @l[2,1,0])
);
}
$cui->set_timer(
'progressbar_demo',
\&progressbar_timer_callback, 1
);
$cui->disable_timer('progressbar_demo');
$w{7}->onFocus( sub{$cui->enable_timer ('progressbar_demo')} );
$w{7}->onBlur( sub{$cui->disable_timer ('progressbar_demo')} );
# ----------------------------------------------------------------------
# Calendar
# ----------------------------------------------------------------------
( run in 1.399 second using v1.01-cache-2.11-cpan-364913b4093 )