|
11 | 11 | from qtpy.QtGui import QDesktopServices, QKeySequence
|
12 | 12 | from qtpy.QtWidgets import (QMainWindow, QWidget, QVBoxLayout, QListWidget, QListWidgetItem, QSplitter, QFileDialog,
|
13 | 13 | QPushButton, QDialogButtonBox, QAction, QShortcut, QHBoxLayout, QGridLayout,
|
14 |
| - QLineEdit, QMessageBox, QDialog) |
| 14 | + QLineEdit, QMessageBox, QDialog, QInputDialog) |
15 | 15 |
|
16 | 16 | try:
|
17 | 17 | from qtconsole.rich_jupyter_widget import RichJupyterWidget
|
@@ -269,6 +269,9 @@ def setup_menu_bar(self):
|
269 | 269 | recent_files_menu.addSeparator()
|
270 | 270 | recent_files_menu.addAction(create_action(self, _('&Clear List'), triggered=self._clear_recent_files))
|
271 | 271 |
|
| 272 | + file_menu.addSeparator() |
| 273 | + file_menu.addAction(create_action(self, _('&Load Example'), triggered=self.load_example)) |
| 274 | + |
272 | 275 | file_menu.addSeparator()
|
273 | 276 | file_menu.addAction(create_action(self, _('&Quit'), shortcut="Ctrl+Q", triggered=self.close))
|
274 | 277 |
|
@@ -643,6 +646,16 @@ def save_as(self):
|
643 | 646 | self._save_data(dialog.selectedFiles()[0])
|
644 | 647 | return accepted
|
645 | 648 |
|
| 649 | + def load_example(self): |
| 650 | + if self._ask_to_save_if_unsaved_modifications(): |
| 651 | + from larray import EXAMPLE_FILES_DIR |
| 652 | + dataset_names = ("demography",) |
| 653 | + dataset_name, ok = QInputDialog.getItem(self, "load dataset example", "list of datasets examples", |
| 654 | + dataset_names, 0, False) |
| 655 | + if ok and dataset_name: |
| 656 | + filepath = os.path.join(EXAMPLE_FILES_DIR, 'data.h5') |
| 657 | + self._open_file(filepath) |
| 658 | + |
646 | 659 | def open_documentation(self):
|
647 | 660 | QDesktopServices.openUrl(QUrl("http://larray.readthedocs.io/en/stable/"))
|
648 | 661 |
|
|
0 commit comments