Skip to content

Commit

Permalink
Add menu action for opening the selected data directory
Browse files Browse the repository at this point in the history
Closes #60
  • Loading branch information
jpgill86 committed Jul 21, 2019
1 parent 286f77a commit 5041253
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions neurotic/gui/standalone.py
Original file line number Diff line number Diff line change
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 5041253

Please sign in to comment.