Thread Pulldown-Menü Tk (14 answers)
Opened by use_Tk at 2011-04-26 19:47

use_Tk
 2011-05-01 17:32
#148173 #148173
User since
2011-03-31
15 Artikel
BenutzerIn

user image
Folgender Code:
Code (perl): (dl )
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');
  }
}


Folgendes Problem: beim Starten kommt der Fehler:
Code: (dl )
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)


Woran ligt das bzw was kann ich dagegen machen?

modedit Editiert von pq: teilbaum "Problem mit Tk::Optionmenu"
Last edited: 2011-05-01 18:42:45 +0200 (CEST)

View full thread Pulldown-Menü Tk