Hi Chad,
I think you did not initialize your listBox.
Create the listBox in the MainWindow or a Frame of the MainWindow as the
example shown:
use strict; # this will show problems
encountered
use warnings;
my $mw=new MainWindow(-title => "Test");
my $mf=$mw->Frame;
# initialize: either the following line
my $listBox=$mw->ScrlListbox( -selectmode => 'multiple', -takefocus => 1,
-width => 70, -height => 20); # within the MainWindow
# or the next one
my $listBox=$mf->ScrlListbox( -selectmode => 'multiple', -takefocus => 1,
-width => 70, -height => 20); # within the frame
$listBox->pack(-side => 'left', -anchor => 'w') ;
my @list = ( "a", "b", "c", "d", "e", "f" );
$listBox->insert('end', @list);
$mf->pack(-side => 'top', -anchor => 'nw');
MainLoop;
If I omit the listBox initialization I get the same error as yours.
Zeray
To: [EMAIL
PROTECTED]
cc: (bcc: Zeray
Abraha/WLR/SC/PHILIPS)
Subject: Tk
Listbox
Chad Lung <[EMAIL PROTECTED]> Classification:
Sent by:
[EMAIL PROTECTED]
.com
2004-10-07 01:46
I'm using the GUI Builder with a simple Perl Tk project. I dropped a
ListBox widget on the form and then wanted to populate the listbox so in
the property editor for the listbox I added a variable to the
"listvariable" property, i.e: @list Then I populate the @list in my
Perl file. Nothing shows up in the ListBox other than "@list", so
obviously I did something wrong. So then I decided to clear out the
@list in the listvariable property and added the following code to the
Perl file:
# BEGIN USER CODE
@list = ( "a", "b", "c", "d", "e", "f" );
$listBox->insert('end', @list);
# END USER CODE
Output: Can't call method "insert" on an undefined value at
C:\PerlSource\TestUI_Dialog.pl line 20.
Any idea what I am doing wrong in either case?
Thanks,
Chad
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
