Changeset 051e22f in sasview for calculatorview/perspectives/calculator
- Timestamp:
- May 3, 2010 4:37:52 PM (15 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 0c0d458
- Parents:
- 67ffb10
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
calculatorview/perspectives/calculator/data_editor.py
r91f151a r051e22f 125 125 data_run_txt = wx.StaticText(self, -1, 'Run : ') 126 126 data_run_txt.SetToolTipString('') 127 self.data_run_tcl = wx.TextCtrl(self, -1, size=(PANEL_WIDTH*3/5, -1)) 128 self.data_run_tcl.Bind(wx.EVT_TEXT_ENTER, self.on_change_run) 127 self.data_run_tcl = wx.TextCtrl(self, -1, size=(PANEL_WIDTH*3/5, -1), style=wx.TE_MULTILINE) 129 128 hint_run = "Data's run." 130 129 self.data_run_tcl.SetToolTipString(hint_run) … … 254 253 self.data_cbox.Clear() 255 254 for data in self._data: 256 pos = self.data_cbox.Append(str(data.filename)) 255 name = data.title 256 if data.run: 257 name = data.run[0] 258 if name.lstrip().rstrip() =="": 259 name = data.filename 260 pos = self.data_cbox.Append(str(name)) 257 261 self.data_cbox.SetClientData(pos, data) 258 262 self.data_cbox.SetSelection(pos) 259 self.data_cbox.SetStringSelection(str(data.filename)) 260 261 263 self.data_cbox.SetStringSelection(str(name)) 264 262 265 def reset_panel(self): 263 266 """ 264 267 """ 265 268 self.enable_data_cbox() 269 self.data_title_tcl.SetValue("") 266 270 self.data_run_tcl.SetValue("") 267 self.data_title_tcl.SetValue("")268 271 269 272 def on_select_data(self, event=None): … … 275 278 return 276 279 self.data_title_tcl.SetValue(str(data.title)) 277 for item in data.run: 278 self.data_run_tcl.AppendText(str(item)) 280 text = "" 281 if data.run: 282 for item in data.run: 283 text += item+"\n" 284 self.data_run_tcl.SetValue(str(text)) 279 285 280 286 def get_current_data(self): 281 287 """ 282 288 """ 283 if not self.data_cbox.IsEnabled():284 return None, None, None285 289 position = self.data_cbox.GetSelection() 286 290 if position == wx.NOT_FOUND: … … 404 408 dlg.ShowModal() 405 409 406 def choose_data_file( parent, location=None):410 def choose_data_file(self, location=None): 407 411 """ 408 412 Open a file dialog to allow loading a file … … 416 420 wlist = '|'.join(cards) 417 421 418 dlg = wx.FileDialog( parent, "Choose a file", location, "", wlist, wx.OPEN)422 dlg = wx.FileDialog(self, "Choose a file", location, "", wlist, wx.OPEN) 419 423 if dlg.ShowModal() == wx.ID_OK: 420 424 path = dlg.GetPath() … … 423 427 return path 424 428 429 425 430 def complete_loading(self, data=None, filename=''): 426 431 """ 427 432 Complete the loading and compute the slit size 428 433 """ 434 self.done = True 429 435 self._data = [] 430 436 if data is None: 431 437 msg = "Couldn't load data" 432 wx.PostEvent(self.parent.parent, StatusEvent(status=msg, type='stop'))438 wx.PostEvent(self.parent.parent, StatusEvent(status=msg, info="warning",type='stop')) 433 439 return 434 440 if not data.__class__.__name__ == "list": … … 436 442 self._reset_data.append(deepcopy(data)) 437 443 else: 438 self._data = d ata444 self._data = deepcopy(data) 439 445 self._reset_data = deepcopy(data) 440 # set data field441 self.reset_panel()442 446 self.set_values() 443 444 447 if self.parent.parent is None: 445 448 return 446 449 msg = "Load Complete" 447 wx.PostEvent(self.parent.parent, StatusEvent(status=msg, 450 wx.PostEvent(self.parent.parent, StatusEvent(status=msg,info="info",type='stop')) 448 451 449 452 def set_values(self): … … 452 455 through the panel 453 456 """ 454 if self._data == []: 455 return 456 self.fill_data_combox() 457 self.on_select_data(event=None) 457 if self._data: 458 self.fill_data_combox() 459 self.on_select_data(event=None) 458 460 459 461 def get_data(self): … … 473 475 Change run 474 476 """ 475 data, data_name, position = self.get_current_data() 477 run = [] 478 data, data_name, position = self.get_current_data() 479 for i in range(self.data_run_tcl.GetNumberOfLines()): 480 run.append(self.data_run_tcl.GetLineText(i).lstrip().rstrip()) 476 481 #Change data's name 477 run = self.data_run_tcl.GetValue().lstrip().rstrip() 478 if run == "": 479 run = [] 482 #run = self.data_run_tcl.GetValue().lstrip().rstrip() 483 480 484 if data.run != run: 481 485 self._notes += "Change data 's " 482 486 self._notes += "run from %s to %s \n"%(data.run, str(run)) 483 data.run = [run]487 data.run = run 484 488 485 489 def on_change_title(self, event=None): … … 502 506 """ 503 507 path = self.choose_data_file(location=self._default_save_location) 504 505 508 if path is None: 506 509 return 510 if self.parent.parent is not None: 511 wx.PostEvent(self.parent.parent, StatusEvent(status="Loading...",info="info", 512 type="progress")) 513 514 self.done = False 507 515 self._default_save_location = path 508 516 try: … … 512 520 if self.reader is not None and self.reader.isrunning(): 513 521 self.reader.stop() 514 if self.parent.parent is not None:515 wx.PostEvent(self.parent.parent, StatusEvent(status="Loading...",516 type="progress"))517 522 self.reader = DataReader(path=path, 518 523 completefn=self.complete_loading,
Note: See TracChangeset
for help on using the changeset viewer.