1
2
3
4
5
$opt = $w->Optionmenu(
-options => REFERENCE_to_OPTIONLIST,
-command => CALLBACK,
-variable => SCALAR_REF,
);
1 2 3 4 5 6 7 8 9 10 11 12 13 14
$listbox = $mw -> Listbox (-selectmode => "single") -> pack(); $optionmenu = $mw -> Optionmenu (-options => [qw/foo bar bla blubb/] -variable => \$var, -command => \&subfunktion ) -> pack(); sub subfunktion{ opendir (FOO, "/usr/share/$var") || die "öffnen: $!"; @foo = readdir FOO; closedir FOO || die "schließen: $!"; foreach $bar (@foo){ $listbox -> insert ('end', '$bar'); } }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
XS_Tk__Callback_Call error:Can't call method "insert" on an undefined value at /etc/perl/chefkoch/list.pm line 30.
Tk::Error: Can't set -options to `ARRAY(0x9d8bd88)' for Tk::Optionmenu=HASH(0x9dcffe0): Can't call method "insert" on an undefined value at /etc/perl/chefkoch/list.pm line 30.
at /usr/lib/perl5/Tk/Derived.pm line 294
at /usr/lib/perl5/Tk/Derived.pm line 306
Tk callback for .frame2
Tk::Derived::configure at /usr/lib/perl5/Tk/Derived.pm line 306
Tk::Widget::new at /usr/lib/perl5/Tk/Widget.pm line 205
Tk::Widget::__ANON__ at /usr/lib/perl5/Tk/Widget.pm line 256
main::list_1 at /etc/perl/chefkoch/list.pm line 15
main::list at ck1.3_main.plx line 61
Tk callback for .frame1.button1
Tk::__ANON__ at /usr/lib/perl5/Tk.pm line 250
Tk::Button::butUp at /usr/lib/perl5/Tk/Button.pm line 175
<ButtonRelease-1>
(command bound to event)