ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> activeperl
activeperl
listbox error
by Tony W. Bass other posts by this author
May 21 2009 5:44PM messages near this date
Calendar in Tkx | RE: listbox error
Hi All,

 

Can anyone explain to me why I get the error:

 

Can't call method "g_bind" without a package or object reference at
C:\scripts\Error Code\listbox_error.pl line 17.

 

Whenever I run the following code. This is put together from a larger
program and if you take out the bind language you get the same basic
error on the curselection statement. This is driving me crazy at this
point. 

 

 

use Tkx;

my $mw = Tkx::widget-> new(".");

$mw-> g_wm_title("Test Program");

(my $nb = $mw-> new_ttk__notebook(-height => 768, -width =>
1024))-> g_grid();

testtab1();

testtab2();

Tkx::MainLoop();

sub testtab1 {

    $tab1 = $nb-> new_ttk__frame(-padding => "10");

    $userbox = $tab1-> new_tk__listbox(-height => 20,
-listvariable=> \$cnames)->g_grid(-column=>1,-row=>1);

    

    $userbox-> g_bind("<<ListboxSelect>>", sub {GetSecurity()});

    $nb-> add($tab1, -text => 'Test Tab', -state=>'hidden');

}

@countrynames = ("Argentina", "Australia", "Belgium", "Brazil",
"Canada", "China", "Denmark", 

        "Finland", "France", "Greece", "India", "Italy", "Japan",
"Mexico", "Netherlands", "Norway", "Spain", 

        "Sweden", "Switzerland");

$cnames = ''; foreach $i (@countrynames) {$cnames = $cnames . ' {' . $i
. '}';};

sub GetSecurity {

    my $u;

    my @idx = $userbox-> curselection;

    if ($#idx==0) {

        $u = $countrynames[$idx[0]];

    }

    print "$u\n";

}

 

Thanks immensely for any help.

 

Tony Bass
Thread:
Tony W. Bass
Brian Raven
Tony W. Bass

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved