[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 | |
---|
[503cc34] | 94 | self.parent.manager.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 | |
---|
[503cc34] | 196 | self.parent.manager.sample = self.metadata |
---|
[2a7722b] | 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 | thickness_label = wx.StaticText(self, -1, "Thickness (mm): ") |
---|
| 217 | input_grid.Add(thickness_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 218 | thickness_input = wx.TextCtrl(self, -1, name="thickness") |
---|
| 219 | input_grid.Add(thickness_input, (y,1), (1,1)) |
---|
| 220 | thickness_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 221 | self._to_validate.append(thickness_input) |
---|
| 222 | y += 1 |
---|
| 223 | |
---|
[1aad14e] | 224 | transmission_label = wx.StaticText(self, -1, "Transmission: ") |
---|
| 225 | input_grid.Add(transmission_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 226 | transmission_input = wx.TextCtrl(self, -1, name="transmission") |
---|
| 227 | input_grid.Add(transmission_input, (y,1), (1,1)) |
---|
| 228 | transmission_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 229 | self._to_validate.append(transmission_input) |
---|
| 230 | y += 1 |
---|
| 231 | |
---|
| 232 | temperature_label = wx.StaticText(self, -1, "Temperature: ") |
---|
| 233 | input_grid.Add(temperature_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 234 | temperature_input = wx.TextCtrl(self, -1, name="temperature") |
---|
| 235 | temperature_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 236 | self._to_validate.append(temperature_input) |
---|
| 237 | input_grid.Add(temperature_input, (y,1), (1,1)) |
---|
| 238 | temp_unit_label = wx.StaticText(self, -1, "Unit: ") |
---|
| 239 | input_grid.Add(temp_unit_label, (y,2), (1,1)) |
---|
| 240 | temp_unit_input = wx.TextCtrl(self, -1, name="temperature_unit", |
---|
| 241 | size=(50,-1)) |
---|
| 242 | temp_unit_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 243 | input_grid.Add(temp_unit_input, (y,3), (1,1)) |
---|
| 244 | y += 1 |
---|
| 245 | |
---|
| 246 | position_label = wx.StaticText(self, -1, "Position (mm): ") |
---|
| 247 | input_grid.Add(position_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 248 | position_input = VectorInput(self, "position") |
---|
| 249 | self._vectors.append(position_input) |
---|
| 250 | input_grid.Add(position_input.GetSizer(), (y,1), (1,2)) |
---|
| 251 | y += 1 |
---|
| 252 | |
---|
| 253 | orientation_label = wx.StaticText(self, -1, "Orientation (\xb0): ") |
---|
| 254 | input_grid.Add(orientation_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 255 | orientation_input = VectorInput(self, "orientation", |
---|
| 256 | labels=["Roll: ", "Pitch: ", "Yaw: "], z_enabled=True) |
---|
| 257 | self._vectors.append(orientation_input) |
---|
| 258 | input_grid.Add(orientation_input.GetSizer(), (y,1), (1,3)) |
---|
| 259 | y += 1 |
---|
| 260 | |
---|
| 261 | details_label = wx.StaticText(self, -1, "Details: ") |
---|
| 262 | input_grid.Add(details_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 263 | details_input = wx.TextCtrl(self, -1, name="details", |
---|
| 264 | style=wx.TE_MULTILINE) |
---|
| 265 | input_grid.Add(details_input, (y,1), (3,3), wx.EXPAND) |
---|
| 266 | y += 3 |
---|
| 267 | |
---|
[2a7722b] | 268 | name_input.SetValue(self.metadata.name) |
---|
[1aad14e] | 269 | thickness_input.SetValue( |
---|
| 270 | self.get_property_string("thickness", is_float=True)) |
---|
| 271 | transmission_input.SetValue( |
---|
| 272 | self.get_property_string("transmission", is_float=True)) |
---|
| 273 | temperature_input.SetValue( |
---|
| 274 | self.get_property_string("temperature", is_float=True)) |
---|
| 275 | temp_unit_input.SetValue(self.get_property_string("temperature_unit")) |
---|
| 276 | position_input.SetValue(self.metadata.position) |
---|
| 277 | orientation_input.SetValue(self.metadata.orientation) |
---|
| 278 | details_input.SetValue(self.get_property_string("details")) |
---|
| 279 | details_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
[2a7722b] | 280 | |
---|
| 281 | done_btn = wx.Button(self, -1, "Done") |
---|
| 282 | input_grid.Add(done_btn, (y,0), (1,1), wx.ALL, 5) |
---|
| 283 | done_btn.Bind(wx.EVT_BUTTON, self.on_close) |
---|
| 284 | |
---|
| 285 | section_sizer.Add(input_grid) |
---|
| 286 | vbox.Add(section_sizer, flag=wx.ALL, border=10) |
---|
| 287 | |
---|
| 288 | vbox.Fit(self) |
---|
| 289 | self.SetSizer(vbox) |
---|
| 290 | |
---|
[55bc56bc] | 291 | class SourcePanel(MetadataPanel): |
---|
| 292 | |
---|
| 293 | def __init__(self, parent, source, base=None, *args, **kwargs): |
---|
| 294 | MetadataPanel.__init__(self, parent, source, base, *args, **kwargs) |
---|
| 295 | if source.name is None: |
---|
| 296 | source.name = '' |
---|
| 297 | source.wavelength_unit = 'nm' |
---|
| 298 | |
---|
| 299 | self._do_layout() |
---|
| 300 | self.SetAutoLayout(True) |
---|
| 301 | self.Layout() |
---|
| 302 | |
---|
| 303 | def on_close(self, event=None): |
---|
| 304 | if not MetadataPanel.on_close(self, event): |
---|
| 305 | return |
---|
| 306 | |
---|
[503cc34] | 307 | self.parent.manager.source = self.metadata |
---|
[55bc56bc] | 308 | self.parent.on_close(event) |
---|
| 309 | |
---|
| 310 | def _do_layout(self): |
---|
| 311 | vbox = wx.BoxSizer(wx.VERTICAL) |
---|
| 312 | |
---|
| 313 | section = wx.StaticBox(self, -1, "Source") |
---|
| 314 | section_sizer = wx.StaticBoxSizer(section, wx.VERTICAL) |
---|
| 315 | section_sizer.SetMinSize((_STATICBOX_WIDTH, -1)) |
---|
| 316 | |
---|
| 317 | input_grid = wx.GridBagSizer(5, 5) |
---|
| 318 | |
---|
| 319 | y = 0 |
---|
| 320 | name_label = wx.StaticText(self, -1, "Name: ") |
---|
| 321 | input_grid.Add(name_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 322 | name_input = wx.TextCtrl(self, -1, name="name") |
---|
| 323 | input_grid.Add(name_input, (y,1), (1,1)) |
---|
| 324 | name_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 325 | y += 1 |
---|
| 326 | |
---|
| 327 | size_label = wx.StaticText(self, -1, "Beam Size (mm): ") |
---|
| 328 | input_grid.Add(size_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 329 | size_input = VectorInput(self, "beam_size") |
---|
| 330 | self._vectors.append(size_input) |
---|
| 331 | input_grid.Add(size_input.GetSizer(), (y,1), (1,1)) |
---|
| 332 | y += 1 |
---|
| 333 | |
---|
| 334 | shape_label = wx.StaticText(self, -1, "Beam Shape: ") |
---|
| 335 | input_grid.Add(shape_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 336 | shape_input = wx.TextCtrl(self, -1, name="beam_shape") |
---|
| 337 | shape_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 338 | input_grid.Add(shape_input, (y,1), (1,1)) |
---|
| 339 | y += 1 |
---|
| 340 | |
---|
| 341 | wavelength_label = wx.StaticText(self, -1, "Wavelength (nm): ") |
---|
| 342 | input_grid.Add(wavelength_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 343 | wavelength_input = wx.TextCtrl(self, -1, name="wavelength", |
---|
| 344 | size=(50,-1)) |
---|
| 345 | wavelength_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 346 | self._to_validate.append(wavelength_input) |
---|
| 347 | input_grid.Add(wavelength_input, (y,1), (1,1)) |
---|
| 348 | y += 1 |
---|
| 349 | |
---|
| 350 | min_wavelength_label = wx.StaticText(self, -1, "Min. Wavelength (nm): ") |
---|
| 351 | input_grid.Add(min_wavelength_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 352 | min_wavelength_input = wx.TextCtrl(self, -1, name="wavelength_min", |
---|
| 353 | size=(50,-1)) |
---|
| 354 | min_wavelength_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 355 | self._to_validate.append(min_wavelength_input) |
---|
| 356 | input_grid.Add(min_wavelength_input, (y,1), (1,1)) |
---|
| 357 | y += 1 |
---|
| 358 | |
---|
| 359 | max_wavelength_label = wx.StaticText(self, -1, "Max. Wavelength (nm): ") |
---|
| 360 | input_grid.Add(max_wavelength_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 361 | max_wavelength_input = wx.TextCtrl(self, -1, name="wavelength_max", |
---|
| 362 | size=(50,-1)) |
---|
| 363 | max_wavelength_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 364 | self._to_validate.append(max_wavelength_input) |
---|
| 365 | input_grid.Add(max_wavelength_input, (y,1), (1,1)) |
---|
| 366 | y += 1 |
---|
| 367 | |
---|
| 368 | wavelength_spread_label = wx.StaticText(self, -1, |
---|
| 369 | "Wavelength Spread (%): ") |
---|
| 370 | input_grid.Add(wavelength_spread_label, (y,0), (1,1), wx.ALL, 5) |
---|
| 371 | wavelength_spread_input = wx.TextCtrl(self, -1, |
---|
| 372 | name="wavelength_spread", size=(50,-1)) |
---|
| 373 | wavelength_spread_input.Bind(wx.EVT_TEXT, self.on_change) |
---|
| 374 | self._to_validate.append(wavelength_spread_input) |
---|
| 375 | input_grid.Add(wavelength_spread_input, (y,1), (1,1)) |
---|
| 376 | y += 1 |
---|
| 377 | |
---|
| 378 | name_input.SetValue(self.get_property_string("name")) |
---|
| 379 | size_input.SetValue(self.metadata.beam_size) |
---|
| 380 | shape_input.SetValue(self.get_property_string("beam_shape")) |
---|
| 381 | wavelength_input.SetValue( |
---|
| 382 | self.get_property_string("wavelength", is_float=True)) |
---|
| 383 | min_wavelength_input.SetValue( |
---|
| 384 | self.get_property_string("wavelength_min", is_float=True)) |
---|
| 385 | max_wavelength_input.SetValue( |
---|
| 386 | self.get_property_string("wavelength_max", is_float=True)) |
---|
| 387 | |
---|
| 388 | done_btn = wx.Button(self, -1, "Done") |
---|
| 389 | input_grid.Add(done_btn, (y,0), (1,1), wx.ALL, 5) |
---|
| 390 | done_btn.Bind(wx.EVT_BUTTON, self.on_close) |
---|
| 391 | |
---|
| 392 | section_sizer.Add(input_grid) |
---|
| 393 | vbox.Add(section_sizer, flag=wx.ALL, border=10) |
---|
| 394 | |
---|
| 395 | vbox.Fit(self) |
---|
| 396 | self.SetSizer(vbox) |
---|
| 397 | |
---|
| 398 | |
---|
[de0df2c] | 399 | class MetadataWindow(widget.CHILD_FRAME): |
---|
[af84162] | 400 | |
---|
[de0df2c] | 401 | def __init__(self, PanelClass, parent=None, title='', base=None, |
---|
| 402 | manager=None, size=(PANEL_SIZE, PANEL_SIZE*0.8), metadata=None, |
---|
[af84162] | 403 | *args, **kwargs): |
---|
| 404 | kwargs['title'] = title |
---|
| 405 | kwargs['size'] = size |
---|
| 406 | widget.CHILD_FRAME.__init__(self, parent, *args, **kwargs) |
---|
| 407 | |
---|
| 408 | self.manager = manager |
---|
[de0df2c] | 409 | self.panel = PanelClass(self, metadata, base=None) |
---|
[af84162] | 410 | self.Bind(wx.EVT_CLOSE, self.on_close) |
---|
| 411 | |
---|
| 412 | def on_close(self, event): |
---|
| 413 | if self.manager is not None: |
---|
[de0df2c] | 414 | self.manager.meta_frames.remove(self) |
---|
[af84162] | 415 | self.Destroy() |
---|