473,396 Members | 1,726 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,396 software developers and data experts.

(Windows) "Dropping" stuff onto a Python script

Hello people,

I'd like to have the functionality known from "real" executables that
if I drag-drop a file icon on top of the app, the app starts and has
the file's path as command-line argument.

However, this doesn't seem to work with Python scripts because Windows
sees those just as files, not apps.

Can this be done?

Thanks,

robert
Nov 6 '08 #1
3 6310
da**********@googlemail.com wrote:
Hello people,

I'd like to have the functionality known from "real" executables that
if I drag-drop a file icon on top of the app, the app starts and has
the file's path as command-line argument.

However, this doesn't seem to work with Python scripts because Windows
sees those just as files, not apps.

Can this be done?
There may be fancier ways but...

.... prefix the shortcut target with the python executable:

c:\python25\python.exe myscript.py

I've just tested this with a script which does this:

<code>
import os, sys

os.startfile (sys.argv[1])

</code>

and it works ok.

TJG
Nov 6 '08 #2
This is done via a drop handler.
Add registry key

HKCR\Python.File\shellex\DropHandler

with a default value of

{86C86720-42A0-1069-A2E8-08002B30309D}

Roger

<da**********@googlemail.comwrote in message
news:b2**********************************@a29g2000 pra.googlegroups.com...
Hello people,

I'd like to have the functionality known from "real" executables that
if I drag-drop a file icon on top of the app, the app starts and has
the file's path as command-line argument.

However, this doesn't seem to work with Python scripts because Windows
sees those just as files, not apps.

Can this be done?

Thanks,

robert
--
http://mail.python.org/mailman/listinfo/python-list


Nov 7 '08 #3
On Nov 6, 2:56*am, daniel.ha...@googlemail.com wrote:
Hello people,

I'd like to have the functionality known from "real" executables that
if I drag-drop a file icon on top of the app, the app starts and has
the file's path as command-line argument.

However, this doesn't seem to work with Python scripts because Windows
sees those just as files, not apps.

Can this be done?

Thanks,

robert
Did someone say dropping stuff? My favorite. Discussions, names,
babies, you get the picture.

I'll take things you drop for $500, Alex.

</humor>
Nov 7 '08 #4

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

Similar topics

20
">"
by: Tim Tyler | last post by:
Should PHP have allowed ">" to be used within PHP tags? e.g. in: if (a > b) { ... }; ....and... $object -> member;
1
by: Seraph | last post by:
I've never posted here before, but I have lurked for quite some time, and have been frustrated to my whits end on what to do about this. Since there is limited support in previous posts (and many...
8
by: Daz | last post by:
Hi all. I would like to make a console application, where I can drag, say, a text file, onto the exe itself, and the console window will popup and tell me what file was dragged onto the exe, (if...
33
by: Snis Pilbor | last post by:
With the "as if" rule in play, doesn't that effectively render the "register" keyword completely useless? Example: I make a silly compiler which creates code that goes out of its way to take a...
4
by: Stef Mientki | last post by:
hello, after 4 months playing around with Python, and I still have troubles with egg files. Sometimes it works, sometimes it doesn't. If I google on "python egg", I get lost of links, which...
5
by: Noozer | last post by:
I'm looking for a "smart folder" program to run on my Windows XP machine. I'm not having any luck finding it and think the logic behind the program is pretty simple, but I'm not sure how I'd...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...

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.