I created a canvas class and shape classes that can save their properties in
XML format. The depricated code in the C++ source was really useful to help
figure out what to save.
I'm not sure that my classes will be useful to the casual programmer. There are
over 10 classes that interact with one another. If all you are interested in is
saving your shape properties to a file, then it would probably be easier to
code it from scratch, using the depricated C++ source as a reference.
Matthew
···
-----Original Message-----
From: Robin Dunn [mailto:robin@alldunn.com]
Sent: Wednesday, September 10, 2003 10:57 AM
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] wxDiagram::LoadFile and SaveFile
Thomas Aanensen wrote:
I would like to store everything on the canvas when I exit my application,
and load it back when I start it up again.
I have noticed the two methods LoadFile and SaveFile in wxDiagram, but the
documentation is a bit weak. It almost seems a bit too easy !
And when I try to do it this way:
self.diagram.SaveFile("graphics")
... I get this error message:
AttributeError: wxDiagram instance has no attribute 'SaveFile'
What am I doing wrong here?
Are ther any other/better ways to do this?
The code that wxOGL uses to load and save has been deprecated and is no
longer in the library. You'll need to iterate through the shapes and
save their attributes yourself.
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
I'm not sure that my classes will be useful to the casual programmer. There
are
over 10 classes that interact with one another. If all you are interested
in is
saving your shape properties to a file, then it would probably be easier to
code it from scratch, using the depricated C++ source as a reference.
Where do I find the source?
Isn't it possible to save the shape instances to a file using cPickle and on
load just create a canvas and use the "AddDiagram" and "Show" methods to put
them on the canvas? Do I really have to create new instances every time? The
properties should follow the instance.
Isn't it possible to save the shape instances to a file using cPickle and on
load just create a canvas and use the "AddDiagram" and "Show" methods to put
them on the canvas? Do I really have to create new instances every time? The
properties should follow the instance.
No because the only thing in the Python objects is a "swigified" reference to a C++ instance and cPickle has no clue about the C++ object, let alone how to pickle it. It would probably be possible to add the appropriate methods (__setstate__ and __getstate__ IIRC) to the Shape classes to allow them to be picklable, but it will have to be done and maintained by someone else as I have no time for it right now.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!