Hi! I'm new here and I'm sorry for my ugly english ... The problem: I'm trying to create this class:
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}); ... ... .. }
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:
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
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!

In reply to Problem with Class and AUTOLOAD with GTK by kapello

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.