Skip to content

Commit

Permalink
Merge pull request #84 from jpgill86/open-data-dir
Browse files Browse the repository at this point in the history
Add menu action for opening the selected data directory
  • Loading branch information
jpgill86 committed Jul 21, 2019
2 parents 286f77a + 5041253 commit 483a1b7
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions neurotic/gui/standalone.py
Expand Up @@ -190,6 +190,10 @@ def create_menus(self):
self.do_download_data.triggered.connect(self.download_files)
self.file_menu.addAction(self.do_download_data)

self.do_open_directory = QT.QAction('Open data &folder', self, shortcut = 'Ctrl+F')
self.do_open_directory.triggered.connect(self.open_directory)
self.file_menu.addAction(self.do_open_directory)

do_launch = QT.QAction('&Launch', self, shortcut = 'Return')
do_launch.triggered.connect(self.launch)
self.file_menu.addAction(do_launch)
Expand Down Expand Up @@ -297,6 +301,28 @@ def on_download_finished(self):
self.do_download_data.setText('&Download data')
self.do_download_data.setEnabled(True)

def open_directory(self):
"""
Open the directory of the selected dataset in Win Explorer / Mac Finder
"""

metadata = self.metadata_selector.selected_metadata
path = metadata['data_dir']

try:

if platform.system() == "Windows":
os.startfile(path)
elif platform.system() == "Darwin":
subprocess.Popen(["open", path])
else:
subprocess.Popen(["xdg-open", path])

except FileNotFoundError as e:

print('The directory for the selected dataset was not found ' \
'locally, perhaps because it does not exist yet:', e)

def launch(self):
"""
Expand Down

0 comments on commit 483a1b7

Please sign in to comment.