|
| 1 | +from pyface.api import ImageResource |
| 2 | +from traits.api import Any, HasTraits, Instance |
| 3 | +from traitsui.api import Action, HGroup, InstanceEditor, Item, VGroup, View |
| 4 | +from traitsui.menu import ToolBar |
| 5 | + |
| 6 | +from diffpy.batchpdfsuite.help import IMAGE_DIR |
| 7 | +from diffpy.batchpdfsuite.refinement_config import RefinementConfig |
| 8 | +from diffpy.batchpdfsuite.refinement_editor import LogDialog |
| 9 | +from diffpy.batchpdfsuite.refinement_io import ( |
| 10 | + SimpleSelectFiles, |
| 11 | + SimpleSelectFolder, |
| 12 | +) |
| 13 | + |
| 14 | +toolbar_settings = Action( |
| 15 | + name="settings", |
| 16 | + action="_settings", |
| 17 | + tooltip="Configure the settings for PDF refinement", |
| 18 | + image=ImageResource(str(IMAGE_DIR / "settings.png")), |
| 19 | +) |
| 20 | +toolbar_refinement_log = Action( |
| 21 | + name="log", |
| 22 | + action="_refinement_log", |
| 23 | + tooltip="Display the runtime output for PDF refinement", |
| 24 | + image=ImageResource(str(IMAGE_DIR / "log.png")), |
| 25 | +) |
| 26 | + |
| 27 | +toolbar_help = Action( |
| 28 | + name="help", |
| 29 | + action="_help", |
| 30 | + tooltip="Quick start", |
| 31 | + image=ImageResource(str(IMAGE_DIR / "help.png")), |
| 32 | +) |
| 33 | + |
| 34 | +toolbar = ToolBar( |
| 35 | + toolbar_settings, |
| 36 | + toolbar_refinement_log, |
| 37 | + toolbar_help, |
| 38 | +) |
| 39 | + |
| 40 | + |
| 41 | +class BatchPDFsuiteGUI(HasTraits): |
| 42 | + splash = Any |
| 43 | + exp_files = Instance(SimpleSelectFolder, ()) |
| 44 | + phase_files = Instance(SimpleSelectFiles, ()) |
| 45 | + refinement_configuration = Instance(RefinementConfig) |
| 46 | + log_dialog = Instance(LogDialog, ()) |
| 47 | + |
| 48 | + def __init__(self, *args, **kargs): |
| 49 | + super().__init__(*args, **kargs) |
| 50 | + self.refinement_configuration = RefinementConfig( |
| 51 | + structure_files_selector=self.phase_files, |
| 52 | + profile_folder_selector=self.exp_files, |
| 53 | + log_dialog=self.log_dialog, |
| 54 | + ) |
| 55 | + if self.splash is not None: |
| 56 | + self.splash.close() |
| 57 | + |
| 58 | + def _refinement_log(self): |
| 59 | + self.log_dialog.edit_traits("log_view") |
| 60 | + return |
| 61 | + |
| 62 | + def _settings(self): |
| 63 | + pass |
| 64 | + |
| 65 | + def _help(self): |
| 66 | + pass |
| 67 | + |
| 68 | + traits_view = View( |
| 69 | + HGroup( |
| 70 | + VGroup( |
| 71 | + Item( |
| 72 | + "exp_files", |
| 73 | + style="custom", |
| 74 | + editor=InstanceEditor(view="traits_view"), |
| 75 | + show_label=False, |
| 76 | + ), |
| 77 | + Item( |
| 78 | + "phase_files", |
| 79 | + style="custom", |
| 80 | + editor=InstanceEditor(view="traits_view"), |
| 81 | + show_label=False, |
| 82 | + ), |
| 83 | + ), |
| 84 | + Item( |
| 85 | + "refinement_configuration", |
| 86 | + style="custom", |
| 87 | + editor=InstanceEditor(view="traits_view"), |
| 88 | + show_label=False, |
| 89 | + ), |
| 90 | + ), |
| 91 | + toolbar=toolbar, |
| 92 | + resizable=True, |
| 93 | + title="Batch PDF Refinement Suite", |
| 94 | + width=800, |
| 95 | + height=600, |
| 96 | + ) |
| 97 | + |
| 98 | + # traits_view = View( |
| 99 | + # HGroup( |
| 100 | + # VGroup( |
| 101 | + # Item( |
| 102 | + # "select_exp_files", |
| 103 | + # editor=InstanceEditor(view="traits_view"), |
| 104 | + # style="custom", |
| 105 | + # width=300, |
| 106 | + # show_label=False, |
| 107 | + # ), |
| 108 | + # Item( |
| 109 | + # "select_phase_files", |
| 110 | + # editor=InstanceEditor(view="traits_view"), |
| 111 | + # style="custom", |
| 112 | + # width=300, |
| 113 | + # show_label=False, |
| 114 | + # ), |
| 115 | + # ), |
| 116 | + # Item( |
| 117 | + # "refinement_configuration", |
| 118 | + # editor=InstanceEditor(view="traits_view"), |
| 119 | + # style="custom", |
| 120 | + # show_label=False, |
| 121 | + # ), |
| 122 | + # ), |
| 123 | + # resizable=True, |
| 124 | + # title="Batch PDF Refinement Suite", |
| 125 | + # width=800, |
| 126 | + # height=600, |
| 127 | + # kind="live", |
| 128 | + # toolbar=toolbar, |
| 129 | + # ) |
0 commit comments