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]>,
Stephen
Watson <[email protected]> wrote:
> Jim Lesurf <[email protected]> wrote:

> > However I've experimented with the SaveBox example and it looks like
> > it runs straight though the python into the mainloop before you even
> > get to drag and drop the icon! Once it goes into mainloop I have no
> > idea (at present) how you would then recover the filename.

> Show the code.

It is based on the example I've taken from the ROX tutorials. At present
the version I have is inside a directory with an AppRun containing

#! /bin/sh

exec xfce4-terminal --hold --execute `dirname $0`/Run.py


And the Run.py file contains

#!/usr/bin/env python

import findrox; findrox.version(1, 9, 8)
import rox

from rox import saving

print "start"

text = """well blow me it works"""

class Lipsum(saving.Saveable):
    def save_to_stream(self, stream):
        print >>stream, text
    
box = saving.SaveBox(Lipsum(), 'Lipsum', 'text/plain')

print "before box show"

box.show()

print "done!"

rox.mainloop()

At this point all I did was add some print statements so I could see the
progress though the code and then ran the above in a terminal where the
results would be printed.

I found that all the words

start
before show box
done

appeared apparently at the same time as the SaveBox popped up on the
desktop. The Savebox then let me drag-and-drop the icon and this created a
file with the expected contents.

The deduction this lead me to is that box.show() pops up the box and the
execution of the code then proceeds into the rox.mainloop() *before* a file
is given a name (by drag and drop) and saved. Thus from my ignorant POV at
present the code 'vanishes into rox.mainloop()' before I can extract the
name of the file that was determined for the drag and drop save.

I have been hoping there was something like 'box.getfilename()'. i.e. a
method called something like 'getfilename' that would attach to the box
process and let me find out the name before the code went into mainloop.
But since I know little about python (and even less about ROX-Lib) this may
be a fantasy on my part!

FWIW I've also used the above for some other modified examples just to play
with python and learn. But they haven't shed any light on the main point
that is of practical interest to me at present - to be able to use dnd to
get a file and filename for subsequent data saving.

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.