#!/usr/bin/perl -w use strict; use File::Temp qw( :POSIX ); use FindBin; use Curses::UI; my $cui = new Curses::UI ( -clear_on_exit => 1, -debug => 0, ); my $current_demo = 1; my %w = (); sub select_demo($;) { my $nr = shift; $current_demo = $nr; $w{$current_demo}->focus; } my $file_menu = [ { -label => 'Quit program',-value => sub {exit(0)}}, ], my $demo_menu = [ { -label => 'Adding a User',-value => sub{select_demo(1)}}, ]; my $menu = [ { -label => 'File',-submenu =>$file_menu}, { -label => 'Select demo',-submenu =>$demo_menu}, ]; $cui->add('menu', 'Menubar', -menu => $menu); my $w0 = $cui->add( 'w0', 'Window', -border => 1, -y => -1, -height => 3, ); $w0->add('explain', 'Label', -text => "CTRL+X: menu CTRL+Q: quit" ); my %screens = ( '1' => 'Adding a User', ); my @screens = sort {$a<=>$b} keys %screens; my %args = ( -border => 1, -titlereverse => 0, -padtop => 2, -padbottom => 3, -ipad => 1, ); while (my ($nr, $title) = each %screens) { my $id = "window_$nr"; $w{$nr} = $cui->add( $id, 'Window', -title => "$title ($nr/" . @screens . ")", %args ); } #Here is where it starts my $rfid; my $emp_id; $w{1}->add( undef, 'Label', -y => -20, -text => "Employee ID", -width => 20, ); $w{1}->add( #undef, 'TextEntry', $emp_id, 'TextEntry', -sbborder => 1, -y => -20, -x => 21, -width => 20, ); # Setup bindings and focus # Bind to quit. $cui->set_binding( sub{ exit }, "\cQ" ); # Bind to menubar. $cui->set_binding( sub{ shift()->root->focus('menu') }, "\cX" ); $w{$current_demo}->focus; # Get things rolling... $cui->mainloop;