1 | """ |
---|
2 | This module provides a GUI for the file converter |
---|
3 | """ |
---|
4 | |
---|
5 | import wx |
---|
6 | import sys |
---|
7 | import numpy as np |
---|
8 | from wx.lib.scrolledpanel import ScrolledPanel |
---|
9 | from sas.sasgui.guiframe.panel_base import PanelBase |
---|
10 | from sas.sasgui.perspectives.calculator import calculator_widgets as widget |
---|
11 | from sas.sasgui.perspectives.file_converter.converter_widgets import VectorInput |
---|
12 | from sas.sasgui.perspectives.file_converter.meta_panels import MetadataWindow |
---|
13 | from sas.sasgui.perspectives.file_converter.meta_panels import DetectorPanel |
---|
14 | from sas.sasgui.perspectives.file_converter.meta_panels import SamplePanel |
---|
15 | from sas.sasgui.perspectives.file_converter.meta_panels import SourcePanel |
---|
16 | from sas.sasgui.perspectives.file_converter.frame_select_dialog import FrameSelectDialog |
---|
17 | from sas.sasgui.guiframe.events import StatusEvent |
---|
18 | from sas.sasgui.guiframe.documentation_window import DocumentationWindow |
---|
19 | from sas.sasgui.guiframe.dataFitting import Data1D |
---|
20 | from sas.sasgui.guiframe.utils import check_float |
---|
21 | from sas.sasgui.perspectives.file_converter.cansas_writer import CansasWriter |
---|
22 | from sas.sasgui.perspectives.file_converter.bsl_loader import BSLLoader |
---|
23 | from sas.sascalc.dataloader.data_info import Detector |
---|
24 | from sas.sascalc.dataloader.data_info import Sample |
---|
25 | from sas.sascalc.dataloader.data_info import Source |
---|
26 | from sas.sascalc.dataloader.data_info import Vector |
---|
27 | |
---|
28 | # Panel size |
---|
29 | if sys.platform.count("win32") > 0: |
---|
30 | PANEL_TOP = 0 |
---|
31 | _STATICBOX_WIDTH = 410 |
---|
32 | _BOX_WIDTH = 200 |
---|
33 | PANEL_SIZE = 480 |
---|
34 | FONT_VARIANT = 0 |
---|
35 | else: |
---|
36 | PANEL_TOP = 60 |
---|
37 | _STATICBOX_WIDTH = 430 |
---|
38 | _BOX_WIDTH = 200 |
---|
39 | PANEL_SIZE = 500 |
---|
40 | FONT_VARIANT = 1 |
---|
41 | |
---|
42 | class ConverterPanel(ScrolledPanel, PanelBase): |
---|
43 | |
---|
44 | def __init__(self, parent, base=None, *args, **kwargs): |
---|
45 | ScrolledPanel.__init__(self, parent, *args, **kwargs) |
---|
46 | PanelBase.__init__(self) |
---|
47 | self.SetupScrolling() |
---|
48 | self.SetWindowVariant(variant=FONT_VARIANT) |
---|
49 | |
---|
50 | self.base = base |
---|
51 | self.parent = parent |
---|
52 | self.meta_frames = [] |
---|
53 | |
---|
54 | self.q_input = None |
---|
55 | self.iq_input = None |
---|
56 | self.output = None |
---|
57 | self.data_type = "ascii" |
---|
58 | |
---|
59 | self.title = None |
---|
60 | self.run = None |
---|
61 | self.run_name = None |
---|
62 | self.instrument = None |
---|
63 | self.detector = Detector() |
---|
64 | self.sample = Sample() |
---|
65 | self.source = Source() |
---|
66 | self.properties = ['title', 'run', 'run_name', 'instrument'] |
---|
67 | |
---|
68 | self.detector.name = '' |
---|
69 | self.source.radiation = 'neutron' |
---|
70 | |
---|
71 | self._do_layout() |
---|
72 | self.SetAutoLayout(True) |
---|
73 | self.Layout() |
---|
74 | |
---|
75 | def convert_to_cansas(self, frame_data, filename, single_file): |
---|
76 | reader = CansasWriter() |
---|
77 | entry_attrs = None |
---|
78 | if self.run_name is not None: |
---|
79 | entry_attrs = { 'name': self.run_name } |
---|
80 | if single_file: |
---|
81 | reader.write(filename, frame_data, |
---|
82 | sasentry_attrs=entry_attrs) |
---|
83 | else: |
---|
84 | # strip extension from filename |
---|
85 | ext = "." + filename.split('.')[-1] |
---|
86 | name = filename.replace(ext, '') |
---|
87 | for i in range(len(frame_data)): |
---|
88 | f_name = "{}{}{}".format(name, i+1, ext) |
---|
89 | reader.write(f_name, [frame_data[i]], |
---|
90 | sasentry_attrs=entry_attrs) |
---|
91 | |
---|
92 | def extract_data(self, filename): |
---|
93 | data = np.loadtxt(filename, dtype=str) |
---|
94 | |
---|
95 | if len(data.shape) != 1: |
---|
96 | msg = "Error reading {}: Only one column of data is allowed" |
---|
97 | raise Exception(msg.format(filename.split('\\')[-1])) |
---|
98 | |
---|
99 | is_float = True |
---|
100 | try: |
---|
101 | float(data[0]) |
---|
102 | except: |
---|
103 | is_float = False |
---|
104 | |
---|
105 | if not is_float: |
---|
106 | end_char = data[0][-1] |
---|
107 | # If lines end with comma or semi-colon, trim the last character |
---|
108 | if end_char == ',' or end_char == ';': |
---|
109 | data = map(lambda s: s[0:-1], data) |
---|
110 | else: |
---|
111 | msg = ("Error reading {}: Lines must end with a digit, comma " |
---|
112 | "or semi-colon").format(filename.split('\\')[-1]) |
---|
113 | raise Exception(msg) |
---|
114 | |
---|
115 | return np.array(data, dtype=np.float32) |
---|
116 | |
---|
117 | def ask_frame_range(self, n_frames): |
---|
118 | valid_input = False |
---|
119 | dlg = FrameSelectDialog(n_frames) |
---|
120 | frames = None |
---|
121 | increment = None |
---|
122 | single_file = True |
---|
123 | while not valid_input: |
---|
124 | if dlg.ShowModal() == wx.ID_OK: |
---|
125 | msg = "" |
---|
126 | try: |
---|
127 | first_frame = int(dlg.first_input.GetValue()) |
---|
128 | last_frame = int(dlg.last_input.GetValue()) |
---|
129 | increment = int(dlg.increment_input.GetValue()) |
---|
130 | single_file = dlg.single_btn.GetValue() |
---|
131 | if last_frame < 0 or first_frame < 0: |
---|
132 | msg = "Frame values must be positive" |
---|
133 | elif increment < 1: |
---|
134 | msg = "Increment must be greater than or equal to 1" |
---|
135 | elif first_frame > last_frame: |
---|
136 | msg = "First frame must be less than last frame" |
---|
137 | elif last_frame > n_frames: |
---|
138 | msg = "Last frame must be less than {}".format(n_frames) |
---|
139 | else: |
---|
140 | valid_input = True |
---|
141 | except: |
---|
142 | valid_input = False |
---|
143 | msg = "Please enter valid integer values" |
---|
144 | |
---|
145 | if not valid_input: |
---|
146 | wx.PostEvent(self.parent.manager.parent, |
---|
147 | StatusEvent(status=msg)) |
---|
148 | else: |
---|
149 | return { 'frames': [], 'inc': None, 'file': single_file } |
---|
150 | frames = range(first_frame, last_frame + increment, |
---|
151 | increment) |
---|
152 | return { 'frames': frames, 'inc': increment, 'file': single_file } |
---|
153 | |
---|
154 | def on_convert(self, event): |
---|
155 | if not self.validate_inputs(): |
---|
156 | return |
---|
157 | |
---|
158 | self.sample.ID = self.title |
---|
159 | |
---|
160 | try: |
---|
161 | if self.data_type == 'ascii': |
---|
162 | qdata = self.extract_data(self.q_input.GetPath()) |
---|
163 | iqdata = self.extract_data(self.iq_input.GetPath()) |
---|
164 | else: # self.data_type == 'bsl' |
---|
165 | loader = BSLLoader(self.q_input.GetPath(), |
---|
166 | self.iq_input.GetPath()) |
---|
167 | bsl_data = loader.load_bsl_data() |
---|
168 | qdata = bsl_data.q_axis.data |
---|
169 | iqdata = bsl_data.data_axis.data |
---|
170 | if len(qdata) > 1: |
---|
171 | msg = ("Q-Axis file has multiple frames. Only 1 frame is " |
---|
172 | "allowed for the Q-Axis") |
---|
173 | wx.PostEvent(self.parent.manager.parent, |
---|
174 | StatusEvent(status=msg, info="error")) |
---|
175 | return |
---|
176 | else: |
---|
177 | qdata = qdata[0] |
---|
178 | frames = [iqdata.shape[0]] |
---|
179 | increment = 1 |
---|
180 | single_file = True |
---|
181 | # Standard file has 3 frames: SAS, calibration and WAS |
---|
182 | if frames[0] > 3: |
---|
183 | # File has multiple frames |
---|
184 | params = self.ask_frame_range(frames[0]) |
---|
185 | frames = params['frames'] |
---|
186 | increment = params['inc'] |
---|
187 | single_file = params['file'] |
---|
188 | if frames == []: return |
---|
189 | else: # Only interested in SAS data |
---|
190 | frames = [0] |
---|
191 | except Exception as ex: |
---|
192 | msg = str(ex) |
---|
193 | wx.PostEvent(self.parent.manager.parent, |
---|
194 | StatusEvent(status=msg, info='error')) |
---|
195 | return |
---|
196 | |
---|
197 | output_path = self.output.GetPath() |
---|
198 | |
---|
199 | if self.run is None: |
---|
200 | self.run = [] |
---|
201 | elif not isinstance(self.run, list): |
---|
202 | self.run = [self.run] |
---|
203 | |
---|
204 | if self.title is None: |
---|
205 | self.title = '' |
---|
206 | |
---|
207 | metadata = { |
---|
208 | 'title': self.title, |
---|
209 | 'run': self.run, |
---|
210 | 'intrument': self.instrument, |
---|
211 | 'detector': [self.detector], |
---|
212 | 'sample': self.sample, |
---|
213 | 'source': self.source |
---|
214 | } |
---|
215 | |
---|
216 | frame_data = [] |
---|
217 | for i in frames: |
---|
218 | data = Data1D(x=qdata, y=iqdata[i]) |
---|
219 | frame_data.append(data) |
---|
220 | if single_file: |
---|
221 | # Only need to set metadata on first Data1D object |
---|
222 | frame_data[0].filename = output_path.split('\\')[-1] |
---|
223 | for key, value in metadata.iteritems(): |
---|
224 | setattr(frame_data[0], key, value) |
---|
225 | else: |
---|
226 | # Need to set metadata for all Data1D objects |
---|
227 | for datainfo in frame_data: |
---|
228 | datainfo.filename = output_path.split('\\')[-1] |
---|
229 | for key, value in metadata.iteritems(): |
---|
230 | setattr(datainfo, key, value) |
---|
231 | |
---|
232 | |
---|
233 | self.convert_to_cansas(frame_data, output_path, single_file) |
---|
234 | wx.PostEvent(self.parent.manager.parent, |
---|
235 | StatusEvent(status="Conversion completed.")) |
---|
236 | |
---|
237 | def on_help(self, event): |
---|
238 | tree_location = ("user/sasgui/perspectives/file_converter/" |
---|
239 | "file_converter_help.html") |
---|
240 | doc_viewer = DocumentationWindow(self, -1, tree_location, |
---|
241 | "", "File Converter Help") |
---|
242 | |
---|
243 | def validate_inputs(self): |
---|
244 | msg = "You must select a" |
---|
245 | if self.q_input.GetPath() == '': |
---|
246 | msg += " Q Axis input file." |
---|
247 | elif self.iq_input.GetPath() == '': |
---|
248 | msg += "n Intensity input file." |
---|
249 | elif self.output.GetPath() == '': |
---|
250 | msg += "destination for the converted file." |
---|
251 | if msg != "You must select a": |
---|
252 | wx.PostEvent(self.parent.manager.parent, |
---|
253 | StatusEvent(status=msg, info='error')) |
---|
254 | return |
---|
255 | |
---|
256 | return True |
---|
257 | |
---|
258 | def show_detector_window(self, event): |
---|
259 | if self.meta_frames != []: |
---|
260 | for frame in self.meta_frames: |
---|
261 | frame.panel.on_close() |
---|
262 | detector_frame = MetadataWindow(DetectorPanel, |
---|
263 | parent=self.parent.manager.parent, manager=self, |
---|
264 | metadata=self.detector, title='Detector Metadata') |
---|
265 | self.meta_frames.append(detector_frame) |
---|
266 | self.parent.manager.put_icon(detector_frame) |
---|
267 | detector_frame.Show(True) |
---|
268 | |
---|
269 | def show_sample_window(self, event): |
---|
270 | if self.meta_frames != []: |
---|
271 | for frame in self.meta_frames: |
---|
272 | frame.panel.on_close() |
---|
273 | sample_frame = MetadataWindow(SamplePanel, |
---|
274 | parent=self.parent.manager.parent, manager=self, |
---|
275 | metadata=self.sample, title='Sample Metadata') |
---|
276 | self.meta_frames.append(sample_frame) |
---|
277 | self.parent.manager.put_icon(sample_frame) |
---|
278 | sample_frame.Show(True) |
---|
279 | |
---|
280 | def show_source_window(self, event): |
---|
281 | if self.meta_frames != []: |
---|
282 | for frame in self.meta_frames: |
---|
283 | frame.panel.on_close() |
---|
284 | source_frame = MetadataWindow(SourcePanel, |
---|
285 | parent=self.parent.manager.parent, manager=self, |
---|
286 | metadata=self.source, title="Source Metadata") |
---|
287 | self.meta_frames.append(source_frame) |
---|
288 | self.parent.manager.put_icon(source_frame) |
---|
289 | source_frame.Show(True) |
---|
290 | |
---|
291 | def on_collapsible_pane(self, event): |
---|
292 | self.Freeze() |
---|
293 | self.SetupScrolling() |
---|
294 | self.parent.Layout() |
---|
295 | self.Thaw() |
---|
296 | |
---|
297 | def datatype_changed(self, event): |
---|
298 | event.Skip() |
---|
299 | dtype = event.GetEventObject().GetName() |
---|
300 | self.data_type = dtype |
---|
301 | |
---|
302 | def radiationtype_changed(self, event): |
---|
303 | event.Skip() |
---|
304 | rtype = event.GetEventObject().GetValue().lower() |
---|
305 | self.source.radiation = rtype |
---|
306 | |
---|
307 | def metadata_changed(self, event): |
---|
308 | event.Skip() |
---|
309 | textbox = event.GetEventObject() |
---|
310 | attr = textbox.GetName() |
---|
311 | value = textbox.GetValue().strip() |
---|
312 | |
---|
313 | if value == '': value = None |
---|
314 | |
---|
315 | setattr(self, attr, value) |
---|
316 | |
---|
317 | |
---|
318 | def _do_layout(self): |
---|
319 | vbox = wx.BoxSizer(wx.VERTICAL) |
---|
320 | |
---|
321 | instructions = ("Select either single column ASCII files or BSL/OTOKO" |
---|
322 | " files containing the Q-Axis and Intensity-axis data, chose where" |
---|
323 | " to save the converted file, then click Convert to convert them " |
---|
324 | "to CanSAS XML format. If required, metadata can also be input " |
---|
325 | "below.") |
---|
326 | instruction_label = wx.StaticText(self, -1, instructions, |
---|
327 | size=(_STATICBOX_WIDTH+40, -1)) |
---|
328 | instruction_label.Wrap(_STATICBOX_WIDTH+40) |
---|
329 | vbox.Add(instruction_label, flag=wx.TOP | wx.LEFT | wx.RIGHT, border=5) |
---|
330 | |
---|
331 | section = wx.StaticBox(self, -1) |
---|
332 | section_sizer = wx.StaticBoxSizer(section, wx.VERTICAL) |
---|
333 | section_sizer.SetMinSize((_STATICBOX_WIDTH, -1)) |
---|
334 | |
---|
335 | input_grid = wx.GridBagSizer(5, 5) |
---|
336 | |
---|
337 | y = 0 |
---|
338 | |
---|
339 | q_label = wx.StaticText(self, -1, "Q-Axis Data: ") |
---|
340 | input_grid.Add(q_label, (y,0), (1,1), wx.ALIGN_CENTER_VERTICAL, 5) |
---|
341 | |
---|
342 | self.q_input = wx.FilePickerCtrl(self, -1, |
---|
343 | size=(_STATICBOX_WIDTH-80, -1), |
---|
344 | message="Chose the Q-Axis data file.") |
---|
345 | input_grid.Add(self.q_input, (y,1), (1,1), wx.ALL, 5) |
---|
346 | y += 1 |
---|
347 | |
---|
348 | iq_label = wx.StaticText(self, -1, "Intensity-Axis Data: ") |
---|
349 | input_grid.Add(iq_label, (y,0), (1,1), wx.ALIGN_CENTER_VERTICAL, 5) |
---|
350 | |
---|
351 | self.iq_input = wx.FilePickerCtrl(self, -1, |
---|
352 | size=(_STATICBOX_WIDTH-80, -1), |
---|
353 | message="Chose the Intensity-Axis data file.") |
---|
354 | input_grid.Add(self.iq_input, (y,1), (1,1), wx.ALL, 5) |
---|
355 | y += 1 |
---|
356 | |
---|
357 | data_type_label = wx.StaticText(self, -1, "Input Format: ") |
---|
358 | input_grid.Add(data_type_label, (y,0), (1,1), |
---|
359 | wx.ALIGN_CENTER_VERTICAL, 5) |
---|
360 | radio_sizer = wx.BoxSizer(wx.HORIZONTAL) |
---|
361 | ascii_btn = wx.RadioButton(self, -1, "ASCII", name="ascii", |
---|
362 | style=wx.RB_GROUP) |
---|
363 | ascii_btn.Bind(wx.EVT_RADIOBUTTON, self.datatype_changed) |
---|
364 | radio_sizer.Add(ascii_btn) |
---|
365 | bsl_btn = wx.RadioButton(self, -1, "BSL/OTOKO", name="bsl") |
---|
366 | bsl_btn.Bind(wx.EVT_RADIOBUTTON, self.datatype_changed) |
---|
367 | radio_sizer.Add(bsl_btn) |
---|
368 | input_grid.Add(radio_sizer, (y,1), (1,1), wx.ALL, 5) |
---|
369 | y += 1 |
---|
370 | |
---|
371 | radiation_label = wx.StaticText(self, -1, "Radiation Type: ") |
---|
372 | input_grid.Add(radiation_label, (y,0), (1,1), wx.ALL, 5) |
---|
373 | radiation_input = wx.ComboBox(self, -1, |
---|
374 | choices=["Neutron", "X-Ray", "Muon", "Electron"], |
---|
375 | name="radiation", style=wx.CB_READONLY, value="Neutron") |
---|
376 | radiation_input.Bind(wx.EVT_COMBOBOX, self.radiationtype_changed) |
---|
377 | input_grid.Add(radiation_input, (y,1), (1,1)) |
---|
378 | y += 1 |
---|
379 | |
---|
380 | output_label = wx.StaticText(self, -1, "Output File: ") |
---|
381 | input_grid.Add(output_label, (y,0), (1,1), wx.ALIGN_CENTER_VERTICAL, 5) |
---|
382 | |
---|
383 | self.output = wx.FilePickerCtrl(self, -1, |
---|
384 | size=(_STATICBOX_WIDTH-80, -1), |
---|
385 | message="Chose where to save the output file.", |
---|
386 | style=wx.FLP_SAVE | wx.FLP_OVERWRITE_PROMPT | wx.FLP_USE_TEXTCTRL, |
---|
387 | wildcard="*.xml") |
---|
388 | input_grid.Add(self.output, (y,1), (1,1), wx.ALL, 5) |
---|
389 | y += 1 |
---|
390 | |
---|
391 | convert_btn = wx.Button(self, wx.ID_OK, "Convert") |
---|
392 | input_grid.Add(convert_btn, (y,0), (1,1), wx.ALL, 5) |
---|
393 | convert_btn.Bind(wx.EVT_BUTTON, self.on_convert) |
---|
394 | |
---|
395 | help_btn = wx.Button(self, -1, "HELP") |
---|
396 | input_grid.Add(help_btn, (y,1), (1,1), wx.ALL, 5) |
---|
397 | help_btn.Bind(wx.EVT_BUTTON, self.on_help) |
---|
398 | |
---|
399 | section_sizer.Add(input_grid) |
---|
400 | |
---|
401 | vbox.Add(section_sizer, flag=wx.ALL, border=5) |
---|
402 | |
---|
403 | metadata_section = wx.CollapsiblePane(self, -1, "Metadata", |
---|
404 | size=(_STATICBOX_WIDTH+40, -1), style=wx.WS_EX_VALIDATE_RECURSIVELY) |
---|
405 | metadata_pane = metadata_section.GetPane() |
---|
406 | metadata_grid = wx.GridBagSizer(5, 5) |
---|
407 | |
---|
408 | metadata_section.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED, |
---|
409 | self.on_collapsible_pane) |
---|
410 | |
---|
411 | y = 0 |
---|
412 | for item in self.properties: |
---|
413 | # Capitalise each word |
---|
414 | label_txt = " ".join( |
---|
415 | [s.capitalize() for s in item.replace('_', ' ').split(' ')]) |
---|
416 | if item == 'run': |
---|
417 | label_txt = "Run Number" |
---|
418 | label = wx.StaticText(metadata_pane, -1, label_txt, |
---|
419 | style=wx.ALIGN_CENTER_VERTICAL) |
---|
420 | input_box = wx.TextCtrl(metadata_pane, name=item, |
---|
421 | size=(_STATICBOX_WIDTH-80, -1)) |
---|
422 | input_box.Bind(wx.EVT_TEXT, self.metadata_changed) |
---|
423 | metadata_grid.Add(label, (y,0), (1,1), |
---|
424 | wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) |
---|
425 | metadata_grid.Add(input_box, (y,1), (1,2), wx.EXPAND) |
---|
426 | y += 1 |
---|
427 | |
---|
428 | detector_label = wx.StaticText(metadata_pane, -1, |
---|
429 | "Detector:") |
---|
430 | metadata_grid.Add(detector_label, (y, 0), (1,1), wx.ALL | wx.EXPAND, 5) |
---|
431 | detector_btn = wx.Button(metadata_pane, -1, "Enter Detector Metadata") |
---|
432 | metadata_grid.Add(detector_btn, (y, 1), (1,1), wx.ALL | wx.EXPAND, 5) |
---|
433 | detector_btn.Bind(wx.EVT_BUTTON, self.show_detector_window) |
---|
434 | y += 1 |
---|
435 | |
---|
436 | sample_label = wx.StaticText(metadata_pane, -1, "Sample: ") |
---|
437 | metadata_grid.Add(sample_label, (y,0), (1,1), wx.ALL | wx.EXPAND, 5) |
---|
438 | sample_btn = wx.Button(metadata_pane, -1, "Enter Sample Metadata") |
---|
439 | metadata_grid.Add(sample_btn, (y,1), (1,1), wx.ALL | wx.EXPAND, 5) |
---|
440 | sample_btn.Bind(wx.EVT_BUTTON, self.show_sample_window) |
---|
441 | y += 1 |
---|
442 | |
---|
443 | source_label = wx.StaticText(metadata_pane, -1, "Source: ") |
---|
444 | metadata_grid.Add(source_label, (y,0), (1,1), wx.ALL | wx.EXPAND, 5) |
---|
445 | source_btn = wx.Button(metadata_pane, -1, "Enter Source Metadata") |
---|
446 | source_btn.Bind(wx.EVT_BUTTON, self.show_source_window) |
---|
447 | metadata_grid.Add(source_btn, (y,1), (1,1), wx.ALL | wx.EXPAND, 5) |
---|
448 | y += 1 |
---|
449 | |
---|
450 | metadata_pane.SetSizer(metadata_grid) |
---|
451 | |
---|
452 | vbox.Add(metadata_section, proportion=0, flag=wx.ALL, border=5) |
---|
453 | |
---|
454 | vbox.Fit(self) |
---|
455 | self.SetSizer(vbox) |
---|
456 | |
---|
457 | class ConverterWindow(widget.CHILD_FRAME): |
---|
458 | |
---|
459 | def __init__(self, parent=None, title='File Converter', base=None, |
---|
460 | manager=None, size=(PANEL_SIZE * 1.05, PANEL_SIZE / 1.25), |
---|
461 | *args, **kwargs): |
---|
462 | kwargs['title'] = title |
---|
463 | kwargs['size'] = size |
---|
464 | widget.CHILD_FRAME.__init__(self, parent, *args, **kwargs) |
---|
465 | |
---|
466 | self.manager = manager |
---|
467 | self.panel = ConverterPanel(self, base=None) |
---|
468 | self.Bind(wx.EVT_CLOSE, self.on_close) |
---|
469 | self.SetPosition((wx.LEFT, PANEL_TOP)) |
---|
470 | self.Show(True) |
---|
471 | |
---|
472 | def on_close(self, event): |
---|
473 | if self.manager is not None: |
---|
474 | self.manager.converter_frame = None |
---|
475 | self.Destroy() |
---|