0

For the past month I've been writing a desktop application for MacOS using Python. It requires opening files and saving compressed data to them. This application creates files using a my own made up extension, so the files are not usable for for other applications. I have almost everything figured out. However, I want to make it so that I can right click on a file with the extension and open it with my python application. I tried using sys.argv to get any arguments for the path of the file to open, but that doesn't work. I know there has to be a way. Preferably there's a builtin variable that is easy to use, but I haven't found anything that helps.

Any help would be useful. Thanks.

  • 1
    https://www.imore.com/how-set-mac-app-default-when-opening-file – Pitto Mar 27 '20 at 19:38
  • That's not quite what I'm looking for. Thanks though! – billschmidt626 Mar 27 '20 at 19:58
  • I am not sure what you want to do... Can you please rephrase? – Pitto Mar 27 '20 at 21:01
  • I have a python script which I've turned into an executable and stuffed into the "MacOS" folder of an application. If you opened the app by itself it would default to an untitled document. You can also open a previously saved document. I'm looking for some python code that will notify the application if the user decides to open the app through a file, by saving the file path to a string – billschmidt626 Mar 27 '20 at 21:08
  • So you want to double click on a file and make it so that Mac Os automatically opens your Python script passing the full path of the file to it? If I got you right then investigate around this functionality: https://www.cnet.com/how-to/add-a-windows-send-to-file-handling-option-to-os-x/ – Pitto Mar 27 '20 at 21:33
  • It's less about the Mac automatically opening the application upon clicking the file. For now I'm only concerned with how the python script can tell that it was opened via a file, and how to get that file path – billschmidt626 Mar 27 '20 at 23:36
  • How can you open a script via a file? – Pitto Mar 28 '20 at 18:35

0 Answers0