Re: [bug] GtkOptionMenu->append()



On Tuesday, April 6, 2004, at 03:12 AM, Pascal Giard wrote:

Unfortunatly,
unless i'm missing something, the problem i was talking about a few weeks back isn't solved
yet...

I'm trying to add menuitems to a GtkOptionMenu.
Before, it was showing messages about GnomeUIInfo, now it doesn't display anything.

So i assumed it was okay now, but when going to the window showing the GtkOptionMenu, i see that
nothing has been added.

Here are the lines i use for testing :
  my $menuitem1 = Gtk2::CheckMenuItem->new_with_label("Patate");
  $menuitem1->set_name("pa");
$xml_root->get_widget("optionmenu_menu_lang")->get_menu- >append($menuitem1);

you still need to ->show your menu items.

show_all() on the window with the option menu will show the menu's children, but if you aren't doing that, you need to show() each menu item you create or they won't be visible.

here's what i used to test this theory:

  use Gtk2 -init;
  my $menu = Gtk2::Menu->new;
  foreach (qw(a b c d e f g)) {
        my $item = Gtk2::MenuItem->new ($_);
        $menu->append ($item);
# uncomment this line to have the items show up
#       $item->show;
  }
  my $option = Gtk2::OptionMenu->new;
  $option->set_menu ($menu);
  my $window = Gtk2::Window->new;
  $window->add ($option);
$menu->show; # if you show all the items but not the menu, it pops up empty
  $option->show;
  $window->show;
  $window->signal_connect (destroy => sub {Gtk2->main_quit});
  Gtk2->main

--
That's it! It's one thing for a ghost to scare my children, but it's another to play my theremin!
  - Homer Simpson




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]