Created
May 31, 2018 22:41
-
-
Save omiq/9afb585a4c099b235937b586c9dbf96c to your computer and use it in GitHub Desktop.
Example of selecting files in the filemanager of mac, windows and linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import subprocess | |
| def select_file(path): | |
| if sys.platform == 'darwin': | |
| subprocess.run(['open', '-R', path]) | |
| elif sys.platform == 'linux': | |
| subprocess.run(['nautilus', path]) | |
| else: | |
| command = 'C:\\windows\\explorer /select,"{}"'.format(path) | |
| print(command) | |
| subprocess.run([command]) | |
| print("{}: {}".format(sys.platform, path)) | |
| file = '/home/chrisg/Pictures/Qt_logo_2016.svg.png' | |
| select_file(file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment