Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add menu action for opening the selected data directory #84

Merged
merged 1 commit into from
Jul 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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