2 Simple utility module to open "explorer" file dialogs.
3 The name "explorer" comes from the windows file explorer, which is called explorer.
5 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
12 """Check if we have support for opening file dialog windows."""
13 if sys.platform == 'win32' or sys.platform == 'cygwin' or sys.platform == 'darwin':
15 if sys.platform == 'linux2':
16 if os.path.isfile('/usr/bin/nautilus'):
18 if os.path.isfile('/usr/bin/dolphin'):
22 def openExplorer(filename):
23 """Open an file dialog window in the directory of a file, and select the file."""
24 if sys.platform == 'win32' or sys.platform == 'cygwin':
25 subprocess.Popen(r'explorer /select,"%s"' % (filename))
26 if sys.platform == 'darwin':
27 subprocess.Popen(['open', '-R', filename])
28 if sys.platform.startswith('linux'):
29 #TODO: On linux we cannot seem to select a certain file, only open the specified path.
30 if os.path.isfile('/usr/bin/nautilus'):
31 subprocess.Popen(['/usr/bin/nautilus', os.path.split(filename)[0]])
32 elif os.path.isfile('/usr/bin/dolphin'):
33 subprocess.Popen(['/usr/bin/dolphin', os.path.split(filename)[0]])
35 def openExplorerPath(filename):
36 """Open a file dialog inside a directory, without selecting any file."""
37 if sys.platform == 'win32' or sys.platform == 'cygwin':
38 subprocess.Popen(r'explorer "%s"' % (filename))
39 if sys.platform == 'darwin':
40 subprocess.Popen(['open', filename])
41 if sys.platform.startswith('linux'):
42 if os.path.isfile('/usr/bin/nautilus'):
43 subprocess.Popen(['/usr/bin/nautilus', filename])
44 elif os.path.isfile('/usr/bin/dolphin'):
45 subprocess.Popen(['/usr/bin/dolphin', filename])