473,614 Members | 2,094 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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\pyt honw.exe c:\mybar\bar.py w
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 2509
On Tue, May 6, 2008 at 9:12 PM, Sizer <Si***@nospam.c omwrote:
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\pyt honw.exe c:\mybar\bar.py w
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\pyt honw.exe c:\mybar\bar.py w
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_RO OT\Python.File\ shellex\DropHan dler]
@="{86C86720-42A0-1069-A2E8-08002B30309D}"
Roger

Jun 27 '08 #3
"Roger Upole" <ru****@hotmail .comwrote in
news:ma******** *************** *************** @python.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_RO OT\Python.File\ shellex\DropHan dler]
@="{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_RO OT\Python.File\ shellex\DropHan dler]
@="{60254CA5-953B-11CF-8C96-00AA00B8708C}"

[HKEY_CLASSES_RO OT\Python.NoCon File\shellex\Dr opHandler]
@="{60254CA5-953B-11CF-8C96-00AA00B8708C}"

[HKEY_CLASSES_RO OT\Python.Compi ledFile\shellex \DropHandler]
@="{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
2584
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: program.exe file.txt When I drop file.txt onto the executable file. In other words, take whatever file dropped onto the executable as the second CLI arugment.
0
3028
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 with 2 file attachements onto a form. I've read everything I could find in MSDN that is relevant and I've got the basic hooks in place: private void MainForm_DragEnter(object sender,
0
1131
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 application to a Windows 2003 Server, the drag & drop no longer functions. The mouse cursor changes to the cursor I specify so i know that the DragEnter event is fine, but when i release, nothing happens.
3
2876
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 application or notepad where i want to paste it to be.How can i do it?If anyone knows source code or any website URL's please let me know. Umasakshi
3
10585
by: VB Programmer | last post by:
In VB.NET 2005 (winform) any sample code to drag & drop items between 2 listboxes? Thanks!
0
482
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 program, but the ActiveX has no support for it, so trying to use it just causes error's. What i have done is use a small label that i use for displaying current progress in the media file to use the drag-and-drop functionality.
9
3549
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 this file and use it instead. however, without even modifying my code first, if i drag and drop a file onto the exe it no longer opens/writes to the files specified by the program. but when no file is dragged onto it, it runs fine as
1
1819
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. These picture boxes are normally populated from a file(s) with a set path and filename. I have this working
0
1369
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 other listbox display the same text but still have the same value behind. so when i submit the lbTo data should read something like Smith John 7A with a value of 657576 for each person in the lbTo.
0
8637
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8285
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8438
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7108
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6092
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5547
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4056
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4131
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.