Hi all,
I was just playing with DnD because I thought that would be nice to have in
my "favorite" python shell.
So this allows to just drag-and-drop a file into the shell- and that
appends:
r"C:\long filename.txt"
So here is my short addition to shell.py in wxWindows/wxPython/
( my version shows:
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id: shell.py,v 1.1.2.5 2003/05/03 16:01:40 PKO Exp $"
__revision__ = "$Revision: 1.1.2.5 $"[11:-2]
)
in
class Shell(editwindow.EditWindow):
<snip>
def __init__(self, <snip>)
<snip>
# I append
#seb: File drag and drop
self.SetDropTarget( FileDropTarget(self) )
<snip>
#at the end of the file
#seb : File drag and drop
class FileDropTarget(wx.FileDropTarget):
def __init__(self, obj):
wx.FileDropTarget.__init__(self)
self.obj = obj
def OnDropFiles(self, x, y, filenames):
txt = 'r\"%s\"' % filenames[0]
n = len(txt)
self.obj.AppendText(n, txt)
pos = self.obj.GetCurrentPos() + n
self.obj.SetCurrentPos( pos )
self.obj.SetSelection( pos, pos )
That seems to be all - the way I get rid of the filename being selected
afterwards (by calling SetSelection) seems to be a hack...
Thanks for this nice shell - I actually didn't know if this is the best
place to post this.
Also I would like to make a note:
The main disadvantage of calling pyCrust now 'py' is that it is now
impossible to 'google' for it...
Maybe everyone can agree to refer to as pyCrust
Have fun and enjoy,
Sebastian Haase