Re: Using drag and drop to set where data should be saved

Jim Lesurf <[email protected]>
Newsgroups gmane.comp.desktop.rox.user
Message-ID <[email protected]>
In article
<[email protected]>,
   Thomas Leonard <[email protected]> wrote:
> On 7 June 2010 17:56, Stephen Watson <[email protected]> wrote:
> > Jim Lesurf <[email protected]> wrote:

[snip]

> >>
> >> and it works quite nicely for A and B above. So I'm hoping that there
> >> is a simple way to extract the full pathname of the file created by
> >> the drag-and-drop and then pass that on to launching the main code.
> >> Is there not a method for reading this name from the class of object
> >> for 'box'.
> > etc?
> >
> > As I recall, the ROX-Lib version expects the call back to create the
> > target file before returning and throws an exception if it doesn't.
> >  You'll need to catch that if you're deferring file creation to a
> > different process.

> Note that you may be asked to save to a temporary file (e.g. when
> transferring data to another program), so it's important not to return
> until the file is written.

> Archive shows how to do it, although it's a bit complicated because it
> supports so many different operations and because it reads and writes at
> the same time.

Being able to read and write at the same time is also something I'd like to
be able to do using dnd since a number of my programs read though one
(often long) wave file and write out results or a modified WAV file as they
go.

> One quick way to get started would be to add your own format to
> Archive/formats.py. Each format is just a shell command that produces
> the output. e.g. this line

>   Archive('zip',	   "zip -qr - '%s'", 'application/zip'),

> means that if the user chooses the "create zip" option then we run the
> command "zip -qr - <name>". You could add your own command here.

> To add your own code, you have a choice of which method to provide:

> 	def save_to_file(self, path): or 	def save_to_stream(self, stream):

> In your case, as you need the name, choose the first.

Ah! :-)  Thanks very much for the above. That is very helpful.

I have been looking at Archive but it has been making blood emerge from my
forehead trying to understand it as I currently know so little about python
and ROX-Lib. The above looks like it will help me a great deal in finding
how to adapt the code to do the kinds of things I have in mind. Excellent. 
:-)

Slainte,

Jim

-- 
Electronics  http://www.st-and.ac.uk/~www_pa/Scots_Guide/intro/electron.htm
Armstrong Audio  http://www.audiomisc.co.uk/Armstrong/armstrong.html
Audio Misc  http://www.audiomisc.co.uk/index.html


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.