0

I'm developing a file system manager in python and I want to make so that when the user clicks a file, it opens in the screen, and if possible I want to implement an open with feature. How can I do this?

I don't even know where to start looking for an answer, because when I Google for it all I find is the open function or the with statement which reads the file to memory which is not what I want. I want to be able to, if the file is an image, use a software installed in the pc, like photos or photoshop to open the image or if it's a spreadsheet use excel to open it.

Note: I'm using Windows, if possible, I'd like a way that works on Windows, Mac and Linux.

raiyan22
  • 1,043
  • 10
  • 20
  • Welcome to Stack Overflow. The reason you have had difficulty with searching is because "opens [the file] in the screen" **does not properly describe** what you want to do. There is not a general-purpose way to "open" a file, because files only contain raw data (bytes) and it is **up to another program** to decide what that data means. Therefore, the question is really: how do I start up another program from Python, and tell it to open the file (the "open with" feature you describe)? – Karl Knechtel Dec 31 '22 at 00:32
  • This is still not focused enough for a proper Stack Overflow question, but the main part - running another program - is explained by the linked duplicate. For each program you want to use, you will need to **read the documentation** in order to figure out a) whether it is intended to be used this way at all; b) what information you need to provide in its command line, and exactly how, so that it will open the file. Separately, you will need to solve the problem of *deciding which program to use*. Depending on your operating system, you may be able to ask yet another program to do this for you. – Karl Knechtel Dec 31 '22 at 00:34
  • As it turns out, "another program" already exists built in for all of Windows, Mac and Linux. I found a more specific duplicate which explains how to do this. – Karl Knechtel Dec 31 '22 at 00:35

0 Answers0