stefan k has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,
I'm just fiddling around with the Perl-Gtk bindings (by the great help of this tutorial) and after removing my code to create menus 'the hard way' I went to the ItemFactory chapter to create menus 'the easy way'.

The problem is this line

$item_factory->create_items( @menu_items );

with a menu_items array that looks like

my @menu_items = ( { path => '/_File', type => '<Branch>' }, { path => '/File/_Quit', accelerator => '<control>Q', callback => \&main_quit }, { path => '/_Hilfe', type => '<LastBranch>' }, { path => '/File/About', callback => \&show_about_msg } );

But perl just says that

Can't locate object method "create_items" via package "Gtk::ItemFactor +y" at ./itemfactory line 114
which is quite sad. There _is_ a method create_item (grep finds it in the binary file auto/Gtk/Gtk.so in the appropriate directory) but that doesn't work with an array of items, at least it seems to me to be that way.

Since the documentation to this great module is ...uhm... not really existant *gg* I ask my fellow monks for advise...

Regards Stefan K

Replies are listed 'Best First'.
Tyop?
by grinder (Bishop) on Apr 03, 2001 at 18:37 UTC

    you sure you don't have a typo somewhere? You talk of create_items and in the next breath talk of create_item.


    --
    g r i n d e r
      Yeah I'm sure and I'm sorry if this has been somewhat unclear.

      In Gtk in C both "methods" exist but in perl only the singular seems to be there whereas in the tutorial the plural form is used.

      Maybe (I can just guess) the plural form takes an array of menu items and the singular form takes them one by one...

      Regards Stefan K

Re: Perl-Gtk: ItemFactory
by busunsl (Vicar) on Apr 03, 2001 at 18:36 UTC
    Just to check:
    $item_factory->create_items( @menu_items );
    does not work, but
    create_item
    exists?

    Well, the difference is just one 's'! :-)