Or alternatively, remove the current script filename from the list using the following if _file_ in sys. What happens in a packaged app will depend on how it’s packaged.įor example, python arguments.py filename.mp4įor opening a file, you could also use sys.argv to get the last argument (if you’re not passing anything else). If you run this with python file.py the file.py will be the first argument in sys.argv. Installing Verify that python is installed and runnning by typing python -version on the command line. from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QVBoxLayoutįor arg in sys.argv: # sys.argv is a list of strings. Can you help me think about it Using command line arguments to open files with PyQt5 apps - Windows.
First, I want to get the file name and path, but I don’t know how to do it. install the PyInstaller package using the following command from the command prompt. The executable allows you to run programs even if you don’t have Python installed. The following app example will display all the command line arguments when run. MP4 file, how to open it with my player I try to open the. PyQt5, googletrans, pyautogui, pywin32, xlrd, xlwt. When Windows tries to open the file with your application, it will pass the filename as an argument to your app – the filename will be available in sys.argv.
If you don’t see your application here, keep scrolling down and you’ll see “Look for another app on this PC” and then you can select your app by EXE file. In the window that opens you’ll see applications that are installed on your computer.
You can set this up by right-clicking on a file in Explorer, selecting Open with… and then “Choose another app”. Hey welcome to the forum! As says you can set your application as the “file handler” for a given file type.