Frage

I'm using perl's Curses::UI to build a ui for a fairly simple script. However, not everything I add to a window is being drawn. Only two things get drawn, the first widget added, and whatever the first widget to get focus is. Executing the code below, only the first TextViewer and then the button are drawn. The 2nd and 3rd TextViewers (for both Windows) aren't drawn. If I make them focusable, and then tab to them, they get drawn. What am I doing wrong?

#!/usr/bin/perl -w
use Curses::UI;

my $cui = new Curses::UI;

my $win = $cui->add(
   'window','Window',
   -border  => 1,
   -title   => 'Test Big Window'
);
$win->add(
   'test0','TextViewer',
   -x => 1,
   -y => 1,
   -text => 'test0',
   -focusable  => 0
);
$win->add(
   'test1','TextViewer',
   -x => 1,
   -y => 2,
   -text => 'test1',
   -focusable  => 0
);
$win->add(
   'test2','TextViewer',
   -x => 1,
   -y => 3,
       -text => 'test2',
   -focusable  => 0
);
$win->add(
   'winButtons','Buttonbox',
   -x => 1,
   -y => 4,
   -buttons => [{-label=>'sub_window',-onpress=>sub{show_win2($win);}}]
);

sub show_win2 {
    $win = shift;
    my $win2 = $win->add(
       'window2','Window',
       -border  => 1,
       -title   => 'Test Little Window',
       -centered   => 1,
       -height  => 20,
       -width   => 40
    );
    $win2->add(
       'test3','TextViewer',
       -x => 1,
       -y => 1,
       -text => 'test3',
       -focusable  => 0
    );
    $win2->add(
       'test4','TextViewer',
       -x => 1,
       -y => 2,
       -text => 'test4',
       -focusable  => 0
    );
    $win2->add(
       'test5','TextViewer',
       -x => 1,
       -y => 3,
       -text => 'test5',
       -focusable  => 0
    );
    my $buttons = $win2->add(
       'addOutputButtons','Buttonbox',
       -buttonalignment  => 'right',
       -bg               => -1,
       -fg               => -1,
       -y                => 4,
       -buttons          => [{-label=>'Exit',-onpress=>sub{exit(0);}}]
    );
    $win2->modalfocus();
}

$cui->mainloop();
$win->modalfocus();

P.S. Is there an easier way to insert code blocks like that, besides manually adding 4 spaces before each line??

Keine korrekte Lösung

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top