|
3 | 3 |
|
4 | 4 | # ETS imports |
5 | 5 | from traits.api import Instance |
| 6 | +from pyface.api import confirm, error, ImageResource |
6 | 7 | from pyface.tasks.api import PaneItem, SplitEditorAreaPane, Task, TaskLayout |
| 8 | +from pyface.tasks.action.api import DockPaneToggleGroup, SGroup, SMenu, \ |
| 9 | + SMenuBar, SToolBar, TaskWindowAction |
| 10 | +from pyface.tasks.action.task_action import TaskAction |
7 | 11 |
|
8 | 12 | # Local imports |
9 | 13 | from .pycasa_browser_pane import PycasaBrowserPane |
@@ -56,3 +60,70 @@ def open_in_central_pane(self, filepath): |
56 | 60 | self.central_pane.edit(obj, factory=ImageFolderEditor) |
57 | 61 | else: |
58 | 62 | print("Unsupported file format: {}".format(file_ext)) |
| 63 | + |
| 64 | + # Menu action methods ----------------------------------------------------- |
| 65 | + |
| 66 | + def request_open_new_path(self): |
| 67 | + pass |
| 68 | + |
| 69 | + def scan_current_path(self): |
| 70 | + pass |
| 71 | + |
| 72 | + # Initialization methods -------------------------------------------------- |
| 73 | + |
| 74 | + def _tool_bars_default(self): |
| 75 | + # No accelerators here: they are added to menu entries |
| 76 | + # Note: Image resources are looked for in an images folder next to the |
| 77 | + # module invoking the resource. |
| 78 | + tool_bars = [ |
| 79 | + SToolBar( |
| 80 | + TaskAction(name='Open...', |
| 81 | + accelerator='Ctrl+N', |
| 82 | + method='request_open_new_path', |
| 83 | + image=ImageResource('document-open')), |
| 84 | + TaskAction(name='Scan', |
| 85 | + accelerator='Ctrl+R', |
| 86 | + method='scan_current_path', |
| 87 | + image=ImageResource('zoom-draw')), |
| 88 | + image_size=(32, 32), show_tool_names=False, id='ToolsBar', |
| 89 | + name='ToolsBar' |
| 90 | + ), |
| 91 | + ] |
| 92 | + return tool_bars |
| 93 | + |
| 94 | + def _menu_bar_default(self): |
| 95 | + menu_bar = SMenuBar( |
| 96 | + SMenu( |
| 97 | + SGroup( |
| 98 | + TaskAction(name='Open...', |
| 99 | + accelerator='Ctrl+N', |
| 100 | + method='request_open_new_path', |
| 101 | + enabled_name='repository.scanned'), |
| 102 | + id='SelectionGroup', name='SelectionGroup', |
| 103 | + ), |
| 104 | + SGroup( |
| 105 | + TaskWindowAction( |
| 106 | + name='Close', |
| 107 | + accelerator='Ctrl+W', |
| 108 | + method='close', |
| 109 | + ), |
| 110 | + id='CloseGroup', name='CloseGroup', |
| 111 | + ), |
| 112 | + id='File', name='&File'), |
| 113 | + SMenu(DockPaneToggleGroup(), |
| 114 | + id='View', name='&View'), |
| 115 | + SMenu( |
| 116 | + SGroup( |
| 117 | + TaskAction(name='Scan', |
| 118 | + accelerator='Ctrl+R', |
| 119 | + method='request_rescan_repository', |
| 120 | + image=ImageResource('zoom-draw')), |
| 121 | + id='RepositoryGroup', name='RepositoryGroup' |
| 122 | + ), |
| 123 | + id='Tools', name='&Tools', |
| 124 | + ), |
| 125 | + SMenu( |
| 126 | + id='Help', name='&Help' |
| 127 | + ) |
| 128 | + ) |
| 129 | + return menu_bar |
0 commit comments