Re: storing Perl-Gtk objects on disk

Cogan, Gil was overheard mumbling something about this on Wed, 13 Sep 2000
06:41:46 -0700

 I've built a Gtk Tree widget, and I tried to save it on disk using
 Data::Dumper and Storable, but it seems that 
 it doesn't work fine - the file to which I dumped the Tree (using
 Data::Dumper) had only the following contents:
  $VAR1 = bless( {
               '_gtk' => 139736072
             }, 'Gtk::TreeItem' );
 it seems that all of the widget's arguments were lost.
 Is it possible to store GUI objects on disk? Should it differ from storing
 'regular' objects?


Gtk+ objects are in C... perl doesn't know anything about them really.  The
"object" methods you call in perl are simply wrappers around the C function
calls.  Besides, what are you really trying to do?  If you simply want to
create a GUI that you can load and save to disk, try looking into libglade...

When you do something like $ctree->set_column_width(0,130) or whatever, really
you are just telling perl to call the gtk_ctree_set_column_width() C
function... Most of Gtk+ objects attributes are private anyway... you use
functions to get and set the attributes of most things (there are a few
exceptions.. but not many)  You are confusing "objects" with "structures" I am
thinking... When you access a Gtk+ widget via the $widget->something() syntax,
->something() is a function, not a value... its not like an anonymous hash that
you can get at via Data::Dumper... syntax is similar, but they are two
completely different things

Otherwise, you would do something like $ctree->{column}[0]->{width} = 130; to
set the width of column 0... that would be accessing the ctree as though it
where a structure... it's not though, so that doesn't work!


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