Curses-UI-POE
view release on metacpan or search on metacpan
examples/demo-widgets view on Meta::CPAN
-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
# ----------------------------------------------------------------------
$w{8}->add(
undef, 'Label',
-text => "The calendar can be used to select a date, somewhere between\n"
. "the years 0 and 9999. It honours the transition from the\n"
. "Julian- to the Gregorian calender in 1752."
);
$w{8}->add(
undef, 'Label',
-y => 5, -x => 27,
-text => "Use your cursor keys (or <H>, <J>, <K> and <L>)\n"
. "to walk through the calender. Press <ENTER>\n"
. "or <SPACE> to select a date. Press <SHIFT+J> to\n"
. "go one month forward and <SHIFT+K> to go one\n"
. "month backward. Press <SHIFT+L> or <N> to go one\n"
. "year forward and <SHIFT+H> or <P> to go one year\n"
. "backward. Press <T> to go to today's date. Press\n"
. "<C> to go to the currently selected date."
);
$w{8}->add(
'calendarlabel', 'Label',
-y => 14, -x => 27,
-bold => 1,
-width => -1,
-text => 'Select a date please...'
);
$w{8}->add(
'calendar', 'Calendar',
-y => 4, -x => 0,
-border => 1,
-onchange => sub {
my $cal = shift;
my $label = $cal->parent->getobj('calendarlabel');
$label->text("You selected the date: " . $cal->get);
},
);
# ----------------------------------------------------------------------
# Dialog::Basic
# ----------------------------------------------------------------------
$w{9}->add(
undef, 'Label',
-text => "Curses::UI::POE has a number of ready-to-use dialog windows.\n"
. "The basic dialog is one of them. It consists of a dialog\n"
. "showing a message and one or more buttons. Press the\n"
. "buttons to see some examples of this."
);
$w{9}->add(
undef, 'Buttonbox',
-y => 7,
-buttons => [
{
-label => "< Example 1 >",
-onpress => sub {
shift()->root->dialog("As basic as it gets")
}
},{
-label => "< Example 2 >",
-onpress => sub {
shift()->root->dialog(
-message => "Basic, but carrying a\n"
. "title this time.",
-title => 'Dialog::Basic demo',
);
}
},{
( run in 0.725 second using v1.01-cache-2.11-cpan-39bf76dae61 )