Does this help? sub on_add { Glib::Idle->add(sub{ Gtk2::Gdk::Threads->enter; Goo::Canvas::Rect->new( $root,100,100,50,120 ); Gtk2::Gdk::Threads->leave; return FALSE; }); }
Regards Mario Am Freitag, den 07.05.2010, 07:07 +0000 schrieb Xi Yang: > #!/usr/bin/perl > use strict; > > use threads; > use threads::shared; > > use Glib qw/TRUE FALSE/; > use Gtk2 qw/-init -threads-init/; > use Goo::Canvas; > > Glib::Object->set_threadsafe(TRUE); > > # create window > my $win = Gtk2::Window->new; > $win->signal_connect( destroy => sub { Gtk2->main_quit; } ); > $win->set_title('children rendering test'); > > my $vbox = Gtk2::VBox->new( FALSE, 6 ); > $win->add($vbox); > > # create Add button > my $hbox = Gtk2::HBox->new(FALSE,6); > $vbox->pack_start($hbox,FALSE,FALSE,0); > > my $but_add_node = Gtk2::Button->new('Add'); > $hbox->pack_start($but_add_node,FALSE,FALSE,0); > $but_add_node->signal_connect('clicked'=>\&on_add); > > # create the c anvas > my $canvas = Goo::Canvas->new(); > my $root = $canvas->get_root_item; > $canvas->set_size_request( 800, 500 ); > $vbox->pack_start( $canvas, FALSE, FALSE, 0 ); > > # enter mainloop > $win->show_all; > Gtk2->main; > > sub on_add { > Gtk2::Gdk::Threads->enter; > Goo::Canvas::Rect->new( > $root,100,100,50,120 > ); > Gtk2::Gdk::Threads->leave; > } _______________________________________________ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list