kapello has asked for the wisdom of the Perl Monks concerning the following question:
When I create the first instance it's ok. But when in the main I try to create a second instance I get this error:package Page; sub new { my ($class,%args) = @_; my $self = Tie::SecureHash->new($class); my $s = Default::Style->new(); $self->{"Page::filename"}=$args{filename} || croak __"Manca il fil +ename (obbligatorio)"; $self->{"Page::name"}=basename($args{filename}); $self->{"Page::style"}=$args{style} || "editor"; $self->{"Page::scrolled"}=Gtk2::ScrolledWindow->new (undef, undef) +; $self->{"Page::sourceview"}=Gtk2::SourceView2::View->new(); $self->{"Page::lm"}=Gtk2::SourceView2::LanguageManager->new(); $self->{"Page::sm"}=Gtk2::SourceView2::StyleSchemeManager->new(); $self->{"Page::buffer"}=$self->{sourceview}->get_buffer(); $self->{"Page::label"}=Gtk2::HBox->new($s->get_box_new_small); $self->{"Page::title"}=Gtk2::Label->new($self->get_name); $self->{"Page::button"}=Gtk2::Button->new(); $self->init(); return $self; } sub init{ my $self = shift; my $a = Default::Actions->new(); my $s = Default::Style->new(); $self->{scrolled}->add($self->get_sourceview); $self->{title}->set_tooltip_text($self->{name}); ... ... .. }
I think this is because of the blessing class is the same ... but the question is: How can I instantiate multiple instance of my class? Thank you!Gtk-WARNING **: Attempting to add a widget with type GtkSourceView to +a container of type GtkScrolledWindow, but the widget is already insi +de a container of type GtkScrolledWindow
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with Class
by ELISHEVA (Prior) on Jan 03, 2011 at 17:55 UTC | |
by kapello (Initiate) on Jan 03, 2011 at 18:36 UTC | |
by lamprecht (Friar) on Jan 03, 2011 at 19:09 UTC | |
by kapello (Initiate) on Jan 03, 2011 at 20:00 UTC |