Open files with double click

In the windowing environment. I would like the user to be able to double-click the data file on their desktop or in one of their folders (or directories) and have the wxPython start up and open their data file.

···

On Wednesday, February 9, 2005, at 04:34 AM, Magnus Lyckå wrote:

brian christensen wrote:

I am sure there must be a way to make a wxPython application open its data files when the user double clicks them.

In what context?
In an open file dialog of your application or just out there in your windowing environment?

That's a function of the windowing environment, not of the
wxPython application. You have to tell your
window/desktop/file manager to take action X when the user
double-clicks on files of type Y.

One presumes the easiest way for the desktop manager to inform
the application of the file on which the user double-clicked is
to pass it in the argv array.

···

On Wed, Feb 09, 2005 at 12:23:29PM -0600, brian christensen wrote:

In the windowing environment. I would like the user to be able
to double-click the data file on their desktop or in one of
their folders (or directories) and have the wxPython start up
and open their data file.

--
Grant Edwards
grante@visi.com

One presumes the easiest way for the desktop manager to inform
the application of the file on which the user double-clicked is
to pass it in the argv array.

I think the problem is that the desktop manager (at least on Windows) can only launch an
executable program with the file that was double-clicked. That is, if you double-click
a '.txt' file, the desktop manager executes something like 'Notepad.exe file.txt'.

But if you want to assign all files with the '.xyz' extension to be automatically opened by
your wxPython my_app.py program, you run into problems. I don't think there's a way to
tell the desktop manager to execute 'python c:\myProgs\my_app.py file.xyz'.

I think one solution to this would be to use something like py2exe to create a standalone
Windows executable my_app.exe that you could assign to all .xyz files.

Another solution might be to create a simple executable that just spawns a
'python c:\my_app.py file.xyz' process. Something like:

int main(int argc, char *argv)
{
    spawn("python C:\\my_app.py" + argv[1]); //completely incorrect syntax but you get the idea
}

Compile this to my_app_launcher.exe, and then associate .xyz files to it.

Eli