473,387 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Can't drag and drop onto .py in Windows XP?

I have several python utils that look at sys.argv to get a list of
filenames to process and mangle the files in various ways. If I have a
bar.bat file in Windows XP then I can just drag foo.avi onto bar.bat and
bar.bat gets called with foo.avi as an argument, everyone's happy. But if I
have a bar.py (or .pyw) and try to drag and drop foo.avi to it, I get a big
NO cursor and nothing happens.

Now I can work around this by creating a _bar.bat and having the _bar.bat
call bar.pyw with the filenames it was passed (this is obviously
ridiculous). Or I can create a shortcut which has the target of
c:\python25\pythonw.exe c:\mybar\bar.pyw
and that works, but makes telling people how to install my utilities on
their computer a pain in the rear. It's just a little weird that I can't
just drag and drop file names onto .pyw or .py files. Am I missing
something here?

Thanks for any help.
Jun 27 '08 #1
3 2496
On Tue, May 6, 2008 at 9:12 PM, Sizer <Si***@nospam.comwrote:
I have several python utils that look at sys.argv to get a list of
filenames to process and mangle the files in various ways. If I have a
bar.bat file in Windows XP then I can just drag foo.avi onto bar.bat and
bar.bat gets called with foo.avi as an argument, everyone's happy. But if I
have a bar.py (or .pyw) and try to drag and drop foo.avi to it, I get a big
NO cursor and nothing happens.

Now I can work around this by creating a _bar.bat and having the _bar.bat
call bar.pyw with the filenames it was passed (this is obviously
ridiculous). Or I can create a shortcut which has the target of
c:\python25\pythonw.exe c:\mybar\bar.pyw
and that works, but makes telling people how to install my utilities on
their computer a pain in the rear. It's just a little weird that I can't
just drag and drop file names onto .pyw or .py files. Am I missing
something here?
I believe the problem is that Windows doesn't view bar.py as an
executable file, but as a data file with an associated launcher. It's
not smart enough to figure out that when you try to drop a file onto a
..py file, you want it to run python.exe with both the .py file and the
dropped file as arguments. I don't think there's any way to change
this behavior, but I could be mistaken.
Jun 27 '08 #2

Sizer wrote:
>I have several python utils that look at sys.argv to get a list of
filenames to process and mangle the files in various ways. If I have a
bar.bat file in Windows XP then I can just drag foo.avi onto bar.bat and
bar.bat gets called with foo.avi as an argument, everyone's happy. But if
I
have a bar.py (or .pyw) and try to drag and drop foo.avi to it, I get a
big
NO cursor and nothing happens.

Now I can work around this by creating a _bar.bat and having the _bar.bat
call bar.pyw with the filenames it was passed (this is obviously
ridiculous). Or I can create a shortcut which has the target of
c:\python25\pythonw.exe c:\mybar\bar.pyw
and that works, but makes telling people how to install my utilities on
their computer a pain in the rear. It's just a little weird that I can't
just drag and drop file names onto .pyw or .py files. Am I missing
something here?

Thanks for any help.
You can register a DropHandler for the Python file class.
Put this in a .reg file and merge it into the registry:

REGEDIT4

[HKEY_CLASSES_ROOT\Python.File\shellex\DropHandler]
@="{86C86720-42A0-1069-A2E8-08002B30309D}"
Roger

Jun 27 '08 #3
"Roger Upole" <ru****@hotmail.comwrote in
news:ma**************************************@pyth on.org:
Sizer wrote:
>It's just a little weird that I
can't just drag and drop file names onto .pyw or .py files. Am I
missing something here?

Thanks for any help.

You can register a DropHandler for the Python file class.
Put this in a .reg file and merge it into the registry:

REGEDIT4

[HKEY_CLASSES_ROOT\Python.File\shellex\DropHandler]
@="{86C86720-42A0-1069-A2E8-08002B30309D}"
Sir, you rock! I found that it actually worked a little better if I used
a generic wsh drop handler instead of the .exe handler, but I would never
have known where to start looking without your suggestion. I ended up
with the following .reg file, and now I can drag and drop files onto my
..py, .pyw, and .pyc files and off they go as you'd expect. It kind of
seems like this should be the default installer behavior unless there's a
good reason not to do it. Thanks again for your help.

REGEDIT4

[HKEY_CLASSES_ROOT\Python.File\shellex\DropHandler]
@="{60254CA5-953B-11CF-8C96-00AA00B8708C}"

[HKEY_CLASSES_ROOT\Python.NoConFile\shellex\DropHan dler]
@="{60254CA5-953B-11CF-8C96-00AA00B8708C}"

[HKEY_CLASSES_ROOT\Python.CompiledFile\shellex\Drop Handler]
@="{60254CA5-953B-11CF-8C96-00AA00B8708C}"
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Patrick Kramer | last post by:
I'm building a file format converter for someone who at best takes more than his fair share of IT helpdesk hours :D So I want to make it as simple as possible. What I want it to do is, run: ...
0
by: Richard | last post by:
Hi, I'm trying to do drag-n-drop from MS Outlook onto a C# form. I'm just proving a concept for management here so we don't need to get fancy; assume I'm dropping an Outlook e-mail message...
0
by: Andy | last post by:
Hi all, I'm developing an application which allows a drag and drop of files onto a ListView control. Everything works fine on my Windows XP development computer, but when i move the...
3
by: Uma sakshi | last post by:
Hi I have one VB.NET application,in that application i have one datagrid control.The datagrid control contains somedata.I want to copy the data in a particular cell and paste it into my C#.NET...
3
by: VB Programmer | last post by:
In VB.NET 2005 (winform) any sample code to drag & drop items between 2 listboxes? Thanks!
0
by: ViRi | last post by:
I am currently experimenting a bit with AxMicrosoft.MediaPlayer.Intero­p.AxWindowsMediaPlayer and so far, most has gone well. Currently, i would like to add drag-and-drop functionality to the...
9
by: Mark | last post by:
hi... i have a program that opens a couple files and performs some operations on them. i wanted to modify my program so that if you drag and drop a file onto the exe via windows, it will open...
1
by: Jeff Williams | last post by:
I am trying to get the following to work so would like some guidance on how to achieve what I need. 1. I have a form which has a tab control. 2. On the 4th TabPage I have 5 picture boxes. 3....
0
by: piercy | last post by:
i have two listboxes, lbData and lbTo. i need to drag and drop between the two. lbData.datasource = tblfilter; i need to be able to drag and drop the data from one to the other then on the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.