[af84162] | 1 | import wx |
---|
| 2 | import sys |
---|
| 3 | from sas.sasgui.perspectives.calculator import calculator_widgets as widget |
---|
| 4 | from sas.sasgui.perspectives.file_converter.converter_widgets import VectorInput |
---|
| 5 | from wx.lib.scrolledpanel import ScrolledPanel |
---|
| 6 | from sas.sasgui.guiframe.panel_base import PanelBase |
---|
| 7 | from sas.sascalc.dataloader.data_info import Detector |
---|
| 8 | from sas.sasgui.guiframe.events import StatusEvent |
---|
| 9 | from sas.sasgui.guiframe.utils import check_float |
---|
| 10 | |
---|
| 11 | if sys.platform.count("win32") > 0: |
---|
| 12 | PANEL_TOP = 0 |
---|
| 13 | _STATICBOX_WIDTH = 350 |
---|
| 14 | PANEL_SIZE = 440 |
---|
| 15 | FONT_VARIANT = 0 |
---|
| 16 | else: |
---|
| 17 | PANEL_TOP = 60 |
---|
| 18 | _STATICBOX_WIDTH = 380 |
---|
| 19 | PANEL_SIZE = 470 |
---|
| 20 | FONT_VARIANT = 1 |
---|
| 21 | |
---|
[de0df2c] | 22 | class MetadataPanel(ScrolledPanel, PanelBase): |
---|
[af84162] | 23 | |
---|
[de0df2c] | 24 | def __init__(self, parent, metadata, base=None, *args, **kwargs): |
---|
[af84162] | 25 | ScrolledPanel.__init__(self, parent, *args, **kwargs) |
---|
| 26 | PanelBase.__init__(self) |
---|
| 27 | self.SetupScrolling() |
---|
| 28 | self.SetWindowVariant(variant=FONT_VARIANT) |
---|
| 29 | |
---|
| 30 | self.base = base |
---|
| 31 | self.parent = parent |
---|
| 32 | self._to_validate = [] |
---|
| 33 | self._vectors = [] |
---|
[de0df2c] | 34 | self.metadata = metadata |
---|
[af84162] | 35 | |
---|
[1aad14e] | 36 | def get_property_string(self, name, is_float=False): |
---|
| 37 | value = getattr(self.metadata, name) |
---|
| 38 | if value is None or value == []: |
---|
| 39 | value = '' |
---|
| 40 | is_float = False |
---|
[9318c4e] | 41 | if isinstance(value, list): |
---|
| 42 | value = value[0] |
---|
[1aad14e] | 43 | value = str(value) |
---|
| 44 | if is_float and not '.' in value: value += '.0' |
---|
| 45 | return value |
---|
| 46 | |
---|
[af84162] | 47 | def on_change(self, event): |
---|
| 48 | ctrl = event.GetEventObject() |
---|
| 49 | value = ctrl.GetValue() |
---|
[1aad14e] | 50 | name = ctrl.GetName() |
---|
| 51 | old_value = getattr(self.metadata, name) |
---|
[af84162] | 52 | if value == '': value = None |
---|
[1aad14e] | 53 | if isinstance(old_value, list): value = [value] |
---|
| 54 | |
---|
| 55 | setattr(self.metadata, name, value) |
---|
[af84162] | 56 | |
---|
| 57 | def on_close(self, event=None): |
---|
| 58 | for ctrl in self._to_validate: |
---|
| 59 | ctrl.SetBackgroundColour(wx.WHITE) |
---|
| 60 | if ctrl.GetValue() == '': continue |
---|
| 61 | if not check_float(ctrl): |
---|
| 62 | msg = "{} must be a valid float".format( |
---|
| 63 | ctrl.GetName().replace("_", " ")) |
---|
| 64 | wx.PostEvent(self.parent.manager.parent.manager.parent, |
---|
| 65 | StatusEvent(status=msg, info='error')) |
---|
[1aad14e] | 66 | return False |
---|
[af84162] | 67 | for vector_in in self._vectors: |
---|
| 68 | is_valid, invalid_ctrl = vector_in.Validate() |
---|
| 69 | if not is_valid: |
---|
| 70 | msg = "{} must be a valid float".format( |
---|
| 71 | invalid_ctrl.GetName().replace("_", " ")) |
---|
| 72 | wx.PostEvent(self.parent.manager.parent.manager.parent, |
---|
| 73 | StatusEvent(status=msg, info='error')) |
---|
[1aad14e] | 74 | return False |
---|
[de0df2c] | 75 | setattr(self.metadata, vector_in.GetName(), vector_in.GetValue()) |
---|
[1aad14e] | 76 | return True |
---|
[de0df2c] | 77 | |
---|
| 78 | class DetectorPanel(MetadataPanel): |
---|
| 79 | |
---|
| 80 | def __init__(self, parent, detector, base=None, *args, **kwargs): |
---|
| 81 | if detector.name is None: |
---|
| 82 | detector.name = '' |
---|
| 83 | |
---|
[2a7722b] | 84 | MetadataPanel.__init__(self, parent, detector, base, *args, **kwargs) |
---|
| 85 | |
---|
[de0df2c] | 86 | self._do_layout() |
---|
| 87 | self.SetAutoLayout(True) |
---|
| 88 | self.Layout() |
---|
| 89 | |
---|
| 90 | def on_close(self, event=None): |
---|
[1aad14e] | 91 | if not MetadataPanel.on_close(self, event): |
---|
| 92 | return |
---|
[af84162] | 93 | |
---|
[de0df2c] | 94 | self.parent.manager.metadata['detector'] = [self.metadata] |
---|
[af84162] | 95 | self.parent.on_close(event) |
---|
| 96 | |
---|
| 97 | def _do_layout(self): |
---|
| 98 | vbox = wx.BoxSizer(wx.VERTICAL) |
---|
| 99 | |
---|
| 100 | section = wx.StaticBox(self, -1, "Detector") |
---|
| 101 | section_sizer = wx.StaticBoxSizer(section, wx.VERTICAL) |
---|
| 102 | section_sizer.SetMinSize((_STATICBOX_WIDTH, -1)) |
---|
| 103 | |
---|
| 104 | input_grid = wx.GridBagSizer(5, 5) |
---|
| 105 | |
---|
| 106 | y = 0 |
---|
| 107 | name_label = wx.StaticText(self, -1, "Name: ") |
---|
| 108 | input_grid.Add(name_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 109 | name_input = wx.TextCtrl(self, -1, name="name") |
---|
| 110 | input_grid.Add(name_input, (y,1), (1,1)) |
---|
| 111 | name_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 112 | y += 1 |
---|
| 113 | |
---|
| 114 | distance_label = wx.StaticText(self, -1, |
---|
| 115 | "Distance (mm): ") |
---|
| 116 | input_grid.Add(distance_label, (y, 0), (1,1), wx.ALL, 5) |
---|
| 117 | distance_input = wx.TextCtrl(self, -1, |
---|
| 118 | name="distance", size=(50,-1)) |
---|
| 119 | input_grid.Add(distance_input, (y,1), (1,1)) |
---|
| 120 | distance_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 121 | self._to_validate.append(distance_input) |
---|
| 122 | y += 1 |
---|
| 123 | |
---|
| 124 | offset_label = wx.StaticText(self, -1, "Offset (mm): ") |
---|
| 125 | input_grid.Add(offset_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 126 | offset_input = VectorInput(self, "offset") |
---|
| 127 | input_grid.Add(offset_input.GetSizer(), (y,1), (1,1)) |
---|
| 128 | self._vectors.append(offset_input) |
---|
| 129 | y += 1 |
---|
| 130 | |
---|
| 131 | orientation_label = wx.StaticText(self, -1, "Orientation (\xb0): ") |
---|
| 132 | input_grid.Add(orientation_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 133 | orientation_input = VectorInput(self, "orientation", z_enabled=True, |
---|
| 134 | labels=["Roll: ", "Pitch: ", "Yaw: "]) |
---|
| 135 | input_grid.Add(orientation_input.GetSizer(), (y,1), (1,1)) |
---|
| 136 | self._vectors.append(orientation_input) |
---|
| 137 | y += 1 |
---|
| 138 | |
---|
| 139 | pixel_label = wx.StaticText(self, -1, "Pixel Size (mm): ") |
---|
| 140 | input_grid.Add(pixel_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 141 | pixel_input = VectorInput(self, "pixel_size") |
---|
| 142 | input_grid.Add(pixel_input.GetSizer(), (y,1), (1,1)) |
---|
| 143 | self._vectors.append(pixel_input) |
---|
| 144 | y += 1 |
---|
| 145 | |
---|
| 146 | beam_label = wx.StaticText(self, -1, "Beam Center (mm): ") |
---|
| 147 | input_grid.Add(beam_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 148 | beam_input = VectorInput(self, "beam_center") |
---|
| 149 | input_grid.Add(beam_input.GetSizer(), (y,1), (1,1)) |
---|
| 150 | self._vectors.append(beam_input) |
---|
| 151 | y += 1 |
---|
| 152 | |
---|
| 153 | slit_label = wx.StaticText(self, -1, "Slit Length (mm): ") |
---|
| 154 | input_grid.Add(slit_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 155 | slit_input = wx.TextCtrl(self, -1, name="slit_length", size=(50,-1)) |
---|
| 156 | input_grid.Add(slit_input, (y,1), (1,1)) |
---|
| 157 | slit_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 158 | self._to_validate.append(slit_input) |
---|
| 159 | y += 1 |
---|
| 160 | |
---|
| 161 | done_btn = wx.Button(self, -1, "Done") |
---|
| 162 | input_grid.Add(done_btn, (y,0), (1,1), wx.ALL, 5) |
---|
| 163 | done_btn.Bind(wx.EVT_BUTTON, self.on_close) |
---|
| 164 | |
---|
| 165 | section_sizer.Add(input_grid) |
---|
| 166 | vbox.Add(section_sizer, flag=wx.ALL, border=10) |
---|
| 167 | |
---|
[de0df2c] | 168 | name_input.SetValue(self.metadata.name) |
---|
[1aad14e] | 169 | distance = self.get_property_string("distance", is_float=True) |
---|
| 170 | distance_input.SetValue(distance) |
---|
[de0df2c] | 171 | offset_input.SetValue(self.metadata.offset) |
---|
| 172 | orientation_input.SetValue(self.metadata.orientation) |
---|
| 173 | pixel_input.SetValue(self.metadata.pixel_size) |
---|
| 174 | beam_input.SetValue(self.metadata.beam_center) |
---|
[1aad14e] | 175 | slit_len = self.get_property_string("slit_length", is_float=True) |
---|
[af84162] | 176 | slit_input.SetValue(slit_len) |
---|
| 177 | |
---|
| 178 | vbox.Fit(self) |
---|
| 179 | self.SetSizer(vbox) |
---|
| 180 | |
---|
[2a7722b] | 181 | class SamplePanel(MetadataPanel): |
---|
| 182 | |
---|
| 183 | def __init__(self, parent, sample, base=None, *args, **kwargs): |
---|
| 184 | MetadataPanel.__init__(self, parent, sample, base, *args, **kwargs) |
---|
[1aad14e] | 185 | if sample.name is None: |
---|
| 186 | sample.name = '' |
---|
[2a7722b] | 187 | |
---|
| 188 | self._do_layout() |
---|
| 189 | self.SetAutoLayout(True) |
---|
| 190 | self.Layout() |
---|
| 191 | |
---|
| 192 | def on_close(self, event=None): |
---|
[1aad14e] | 193 | if not MetadataPanel.on_close(self, event): |
---|
| 194 | return |
---|
[2a7722b] | 195 | |
---|
| 196 | self.parent.manager.metadata['sample'] = self.metadata |
---|
| 197 | self.parent.on_close(event) |
---|
| 198 | |
---|
| 199 | def _do_layout(self): |
---|
| 200 | vbox = wx.BoxSizer(wx.VERTICAL) |
---|
| 201 | |
---|
| 202 | section = wx.StaticBox(self, -1, "Sample") |
---|
| 203 | section_sizer = wx.StaticBoxSizer(section, wx.VERTICAL) |
---|
| 204 | section_sizer.SetMinSize((_STATICBOX_WIDTH, -1)) |
---|
| 205 | |
---|
| 206 | input_grid = wx.GridBagSizer(5, 5) |
---|
| 207 | |
---|
| 208 | y = 0 |
---|
| 209 | name_label = wx.StaticText(self, -1, "Name: ") |
---|
| 210 | input_grid.Add(name_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 211 | name_input = wx.TextCtrl(self, -1, name="name") |
---|
| 212 | input_grid.Add(name_input, (y,1), (1,1)) |
---|
| 213 | name_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 214 | y += 1 |
---|
| 215 | |
---|
| 216 | id_label = wx.StaticText(self, -1, "ID: ") |
---|
| 217 | input_grid.Add(id_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 218 | id_input = wx.TextCtrl(self, -1, name="ID") |
---|
| 219 | input_grid.Add(id_input, (y,1), (1,1)) |
---|
| 220 | id_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 221 | y += 1 |
---|
| 222 | |
---|
| 223 | thickness_label = wx.StaticText(self, -1, "Thickness (mm): ") |
---|
| 224 | input_grid.Add(thickness_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 225 | thickness_input = wx.TextCtrl(self, -1, name="thickness") |
---|
| 226 | input_grid.Add(thickness_input, (y,1), (1,1)) |
---|
| 227 | thickness_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 228 | self._to_validate.append(thickness_input) |
---|
| 229 | y += 1 |
---|
| 230 | |
---|
[1aad14e] | 231 | transmission_label = wx.StaticText(self, -1, "Transmission: ") |
---|
| 232 | input_grid.Add(transmission_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 233 | transmission_input = wx.TextCtrl(self, -1, name="transmission") |
---|
| 234 | input_grid.Add(transmission_input, (y,1), (1,1)) |
---|
| 235 | transmission_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 236 | self._to_validate.append(transmission_input) |
---|
| 237 | y += 1 |
---|
| 238 | |
---|
| 239 | temperature_label = wx.StaticText(self, -1, "Temperature: ") |
---|
| 240 | input_grid.Add(temperature_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 241 | temperature_input = wx.TextCtrl(self, -1, name="temperature") |
---|
| 242 | temperature_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 243 | self._to_validate.append(temperature_input) |
---|
| 244 | input_grid.Add(temperature_input, (y,1), (1,1)) |
---|
| 245 | temp_unit_label = wx.StaticText(self, -1, "Unit: ") |
---|
| 246 | input_grid.Add(temp_unit_label, (y,2), (1,1)) |
---|
| 247 | temp_unit_input = wx.TextCtrl(self, -1, name="temperature_unit", |
---|
| 248 | size=(50,-1)) |
---|
| 249 | temp_unit_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 250 | input_grid.Add(temp_unit_input, (y,3), (1,1)) |
---|
| 251 | y += 1 |
---|
| 252 | |
---|
| 253 | position_label = wx.StaticText(self, -1, "Position (mm): ") |
---|
| 254 | input_grid.Add(position_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 255 | position_input = VectorInput(self, "position") |
---|
| 256 | self._vectors.append(position_input) |
---|
| 257 | input_grid.Add(position_input.GetSizer(), (y,1), (1,2)) |
---|
| 258 | y += 1 |
---|
| 259 | |
---|
| 260 | orientation_label = wx.StaticText(self, -1, "Orientation (\xb0): ") |
---|
| 261 | input_grid.Add(orientation_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 262 | orientation_input = VectorInput(self, "orientation", |
---|
| 263 | labels=["Roll: ", "Pitch: ", "Yaw: "], z_enabled=True) |
---|
| 264 | self._vectors.append(orientation_input) |
---|
| 265 | input_grid.Add(orientation_input.GetSizer(), (y,1), (1,3)) |
---|
| 266 | y += 1 |
---|
| 267 | |
---|
| 268 | details_label = wx.StaticText(self, -1, "Details: ") |
---|
| 269 | input_grid.Add(details_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 270 | details_input = wx.TextCtrl(self, -1, name="details", |
---|
| 271 | style=wx.TE_MULTILINE) |
---|
| 272 | input_grid.Add(details_input, (y,1), (3,3), wx.EXPAND) |
---|
| 273 | y += 3 |
---|
| 274 | |
---|
[2a7722b] | 275 | name_input.SetValue(self.metadata.name) |
---|
[1aad14e] | 276 | id_input.SetValue(self.get_property_string("ID")) |
---|
| 277 | thickness_input.SetValue( |
---|
| 278 | self.get_property_string("thickness", is_float=True)) |
---|
| 279 | transmission_input.SetValue( |
---|
| 280 | self.get_property_string("transmission", is_float=True)) |
---|
| 281 | temperature_input.SetValue( |
---|
| 282 | self.get_property_string("temperature", is_float=True)) |
---|
| 283 | temp_unit_input.SetValue(self.get_property_string("temperature_unit")) |
---|
| 284 | position_input.SetValue(self.metadata.position) |
---|
| 285 | orientation_input.SetValue(self.metadata.orientation) |
---|
| 286 | details_input.SetValue(self.get_property_string("details")) |
---|
| 287 | details_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
[2a7722b] | 288 | |
---|
| 289 | done_btn = wx.Button(self, -1, "Done") |
---|
| 290 | input_grid.Add(done_btn, (y,0), (1,1), wx.ALL, 5) |
---|
| 291 | done_btn.Bind(wx.EVT_BUTTON, self.on_close) |
---|
| 292 | |
---|
| 293 | section_sizer.Add(input_grid) |
---|
| 294 | vbox.Add(section_sizer, flag=wx.ALL, border=10) |
---|
| 295 | |
---|
| 296 | vbox.Fit(self) |
---|
| 297 | self.SetSizer(vbox) |
---|
| 298 | |
---|
[55bc56bc] | 299 | class SourcePanel(MetadataPanel): |
---|
| 300 | |
---|
| 301 | def __init__(self, parent, source, base=None, *args, **kwargs): |
---|
| 302 | MetadataPanel.__init__(self, parent, source, base, *args, **kwargs) |
---|
| 303 | if source.name is None: |
---|
| 304 | source.name = '' |
---|
| 305 | source.wavelength_unit = 'nm' |
---|
| 306 | |
---|
| 307 | self._do_layout() |
---|
| 308 | self.SetAutoLayout(True) |
---|
| 309 | self.Layout() |
---|
| 310 | |
---|
| 311 | def on_close(self, event=None): |
---|
| 312 | if not MetadataPanel.on_close(self, event): |
---|
| 313 | return |
---|
| 314 | |
---|
| 315 | self.parent.manager.metadata['source'] = self.metadata |
---|
| 316 | self.parent.on_close(event) |
---|
| 317 | |
---|
| 318 | def _do_layout(self): |
---|
| 319 | vbox = wx.BoxSizer(wx.VERTICAL) |
---|
| 320 | |
---|
| 321 | section = wx.StaticBox(self, -1, "Source") |
---|
| 322 | section_sizer = wx.StaticBoxSizer(section, wx.VERTICAL) |
---|
| 323 | section_sizer.SetMinSize((_STATICBOX_WIDTH, -1)) |
---|
| 324 | |
---|
| 325 | input_grid = wx.GridBagSizer(5, 5) |
---|
| 326 | |
---|
| 327 | y = 0 |
---|
| 328 | name_label = wx.StaticText(self, -1, "Name: ") |
---|
| 329 | input_grid.Add(name_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 330 | name_input = wx.TextCtrl(self, -1, name="name") |
---|
| 331 | input_grid.Add(name_input, (y,1), (1,1)) |
---|
| 332 | name_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 333 | y += 1 |
---|
| 334 | |
---|
| 335 | radiation_label = wx.StaticText(self, -1, "Radiation: ") |
---|
| 336 | input_grid.Add(radiation_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 337 | radiation_input = wx.ComboBox(self, -1, |
---|
| 338 | choices=["neutron", "x-ray", "muon", "electron"], |
---|
| 339 | name="radiation", style=wx.CB_READONLY) |
---|
| 340 | radiation_input.Bind(wx.EVT_COMBOBOX, self.on_change) |
---|
| 341 | input_grid.Add(radiation_input, (y,1), (1,1)) |
---|
| 342 | y += 1 |
---|
| 343 | |
---|
| 344 | size_label = wx.StaticText(self, -1, "Beam Size (mm): ") |
---|
| 345 | input_grid.Add(size_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 346 | size_input = VectorInput(self, "beam_size") |
---|
| 347 | self._vectors.append(size_input) |
---|
| 348 | input_grid.Add(size_input.GetSizer(), (y,1), (1,1)) |
---|
| 349 | y += 1 |
---|
| 350 | |
---|
| 351 | shape_label = wx.StaticText(self, -1, "Beam Shape: ") |
---|
| 352 | input_grid.Add(shape_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 353 | shape_input = wx.TextCtrl(self, -1, name="beam_shape") |
---|
| 354 | shape_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 355 | input_grid.Add(shape_input, (y,1), (1,1)) |
---|
| 356 | y += 1 |
---|
| 357 | |
---|
| 358 | wavelength_label = wx.StaticText(self, -1, "Wavelength (nm): ") |
---|
| 359 | input_grid.Add(wavelength_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 360 | wavelength_input = wx.TextCtrl(self, -1, name="wavelength", |
---|
| 361 | size=(50,-1)) |
---|
| 362 | wavelength_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 363 | self._to_validate.append(wavelength_input) |
---|
| 364 | input_grid.Add(wavelength_input, (y,1), (1,1)) |
---|
| 365 | y += 1 |
---|
| 366 | |
---|
| 367 | min_wavelength_label = wx.StaticText(self, -1, "Min. Wavelength (nm): ") |
---|
| 368 | input_grid.Add(min_wavelength_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 369 | min_wavelength_input = wx.TextCtrl(self, -1, name="wavelength_min", |
---|
| 370 | size=(50,-1)) |
---|
| 371 | min_wavelength_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 372 | self._to_validate.append(min_wavelength_input) |
---|
| 373 | input_grid.Add(min_wavelength_input, (y,1), (1,1)) |
---|
| 374 | y += 1 |
---|
| 375 | |
---|
| 376 | max_wavelength_label = wx.StaticText(self, -1, "Max. Wavelength (nm): ") |
---|
| 377 | input_grid.Add(max_wavelength_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 378 | max_wavelength_input = wx.TextCtrl(self, -1, name="wavelength_max", |
---|
| 379 | size=(50,-1)) |
---|
| 380 | max_wavelength_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 381 | self._to_validate.append(max_wavelength_input) |
---|
| 382 | input_grid.Add(max_wavelength_input, (y,1), (1,1)) |
---|
| 383 | y += 1 |
---|
| 384 | |
---|
| 385 | wavelength_spread_label = wx.StaticText(self, -1, |
---|
| 386 | "Wavelength Spread (%): ") |
---|
| 387 | input_grid.Add(wavelength_spread_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 388 | wavelength_spread_input = wx.TextCtrl(self, -1, |
---|
| 389 | name="wavelength_spread", size=(50,-1)) |
---|
| 390 | wavelength_spread_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 391 | self._to_validate.append(wavelength_spread_input) |
---|
| 392 | input_grid.Add(wavelength_spread_input, (y,1), (1,1)) |
---|
| 393 | y += 1 |
---|
| 394 | |
---|
| 395 | |
---|
| 396 | name_input.SetValue(self.get_property_string("name")) |
---|
| 397 | radiation_input.SetValue(self.get_property_string("radiation")) |
---|
| 398 | size_input.SetValue(self.metadata.beam_size) |
---|
| 399 | shape_input.SetValue(self.get_property_string("beam_shape")) |
---|
| 400 | wavelength_input.SetValue( |
---|
| 401 | self.get_property_string("wavelength", is_float=True)) |
---|
| 402 | min_wavelength_input.SetValue( |
---|
| 403 | self.get_property_string("wavelength_min", is_float=True)) |
---|
| 404 | max_wavelength_input.SetValue( |
---|
| 405 | self.get_property_string("wavelength_max", is_float=True)) |
---|
| 406 | |
---|
| 407 | done_btn = wx.Button(self, -1, "Done") |
---|
| 408 | input_grid.Add(done_btn, (y,0), (1,1), wx.ALL, 5) |
---|
| 409 | done_btn.Bind(wx.EVT_BUTTON, self.on_close) |
---|
| 410 | |
---|
| 411 | section_sizer.Add(input_grid) |
---|
| 412 | vbox.Add(section_sizer, flag=wx.ALL, border=10) |
---|
| 413 | |
---|
| 414 | vbox.Fit(self) |
---|
| 415 | self.SetSizer(vbox) |
---|
| 416 | |
---|
| 417 | |
---|
[de0df2c] | 418 | class MetadataWindow(widget.CHILD_FRAME): |
---|
[af84162] | 419 | |
---|
[de0df2c] | 420 | def __init__(self, PanelClass, parent=None, title='', base=None, |
---|
| 421 | manager=None, size=(PANEL_SIZE, PANEL_SIZE*0.8), metadata=None, |
---|
[af84162] | 422 | *args, **kwargs): |
---|
| 423 | kwargs['title'] = title |
---|
| 424 | kwargs['size'] = size |
---|
| 425 | widget.CHILD_FRAME.__init__(self, parent, *args, **kwargs) |
---|
| 426 | |
---|
| 427 | self.manager = manager |
---|
[de0df2c] | 428 | self.panel = PanelClass(self, metadata, base=None) |
---|
[af84162] | 429 | self.Bind(wx.EVT_CLOSE, self.on_close) |
---|
| 430 | |
---|
| 431 | def on_close(self, event): |
---|
| 432 | if self.manager is not None: |
---|
[de0df2c] | 433 | self.manager.meta_frames.remove(self) |
---|
[af84162] | 434 | self.Destroy() |
---|