Gtk2 and inheritance



Hi,

it looks like inheriting from Gtk2 classes doesn't work. I get this 
error message:

  Modification of a read-only value attempted 

when I try to bless a Gtk2 widget reference to another class, e.g.:

  package My::Entry;

  use base 'Gtk2::Entry';

  sub new {
    my $class = shift;

    my $self = Gtk2::Entry->new;

    return bless $self, $class;
  }

With Gtk this works. Gtk2 stores the objects internally as scalar refs 
(I suppose it's is the corresponding C pointer), while Gtk uses hash 
refs, which could be reblessed without problems (also it was easy to 
attach user data to arbitrary widget objects - but that's not that 
important here... ;)

Any idea how we could get inheritence working with the current Perl/Gtk2
architecture?

Regards,

Joern

-- 
Think, before you code.




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