views:

76

answers:

1

Ok, so the title may trick you a bit, and I'm sorry for that but didn't find a better title.

This question might be a bit hard to understand so I'll try my best.

I have no idea how this works or if it is even possible but what I want to do is for example create a file type (lets imagine .test (in which a random file name would be random.test)). Now before I continue, its obviously easy to do this using for example:

filename = "random.test"
file = open(filename, 'w')
file.write("some text here")

But now what I would like to know is if it is possible to write the file .test so if I set it to open with a wxPython program (directly (running the "random.test" from the desktop)), it recognizes it and for example opens up a Message Dialog automatically.

I'm sorry if I'm being vague and in case you don't understand, let me know so I can try my best to explain you.

+2  A: 

How this works varies by operating system, but, AFAIK, the general rule is that if you register your application with the operating system as recognizing that file type, then clicking on one or more files of that type causes the operating system to invoke your program with the names of the files as parameters, so your program will correctly handle the file opening if it has a commandline invocation of the following form:

program_name [options] <file1> [<file2> ... <fileN>]

In terms of identifying what file types your program can accept... on Mac OS X, this is done by listing the file types in the application bundle's "Info.plist" file in a dictionary with key CFBundleDocumentTypes. It is up to the user to perform the association, but the information in "Info.plist" determines which applications are considered candidates for registration. On Windows, you need to edit the registry to associate the program with the file type, you can also edit the registry to add "verbs" (right-click menu items) for your program.

Michael Aaron Safyan
Thanks alot for your help! I'm going to check them out as soon as I have time!
Francisco Aleixo