-3

I have made a very basic Tkinter text editor app. I don't think my code will be necessary for this question as I have written no code related to this question yet. I converted my App to a .exe file using Pyinstaller.

For the most part it works, but when I try to use "Open With" of a file to open it with my App, it gives me an error, "Unable to execute CodePad" (CodePad is the name of my app). I experienced this error in the early days of this app's development when it didn't work. But now, it does work when I click on it, but doesn't when I use "Open With". Note: The "Open" button in my file menu still works.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Ultra
  • 21
  • 2
  • Just making it the default app won't make it work by itself, you will also need to modify the app to accept a command-line argument that's the file to open. How to do that will depend on how you converted your script to and .exe. – martineau Feb 22 '20 at 10:05
  • I converted my script to .exe using pyinstaller, can you check and tell me what my command-line argument would be – Ultra Feb 26 '20 at 11:18
  • If it's not described in the pyinstaller documentation, then you may be able to use `sys.argv` like a normal python app. That sounds like what the answer to [after compiling python program, how to input arguments](https://stackoverflow.com/questions/25984395/after-compiling-python-program-how-to-input-arguments) is saying, basically. – martineau Feb 26 '20 at 11:24
  • I am actually not that good at python, I've heard of command-line arguments but don't know how to run them or what they do, can you explain it to me? – Ultra Feb 26 '20 at 11:27
  • Command-line arguments are the items that, when a program is run from a text console, appear after the program's name. There can be more than one and if so they are delimited by space characters. They end up being put into a the list named `sys.argv` which a Python program can access to determine what they were (if any). When a program is launched clicking on a data file by the graphical Windows OS, it passes the name of the file to the default application associated with that file type to the application in the same way as the first command-line argument would have been. – martineau Feb 26 '20 at 11:41
  • If I send you a basic code of my app, will you be able to figure out the correct command-line, I checked out command-line arguments myself and I'm pretty sure ur right, they are what I need – Ultra Feb 27 '20 at 09:53
  • Sorry, you should just try it yourself. The first argument, the file name, should be in `sys.argv[1]` — if `argv`'s length is at least two. – martineau Feb 27 '20 at 10:00
  • okay, thanks any way, you helped me a lot! – Ultra Feb 27 '20 at 10:03
  • I will close this thing if I don't have anymore doubts – Ultra Feb 27 '20 at 10:03
  • okay Thanks, I got it! – Ultra Feb 27 '20 at 10:12
  • Now how do I turn the discussion off? – Ultra Feb 27 '20 at 10:12
  • You can delete your question. – martineau Feb 27 '20 at 10:13

1 Answers1

0

File type associations are defined in Registry. A simple way to do this is using InnoSetup for installer. It can register the necessary association:

http://www.jrsoftware.org/isfaq.php#assoc

i486
  • 6,491
  • 4
  • 24
  • 41
  • I actually did use Inno Setup Compiler to make a setup for my app, but I'm guessing that martineau is right, I have to change something in the code to interact with pyinstaller – Ultra Feb 26 '20 at 11:20