Changeset 743f480 in sasview for calculatorview/src
- Timestamp:
- Jun 26, 2012 1:35:21 PM (12 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:
- 709cd83
- Parents:
- 21bc81b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
calculatorview/src/sans/perspectives/calculator/data_operator.py
r21bc81b r743f480 57 57 self.output = None 58 58 self._notes = None 59 #text grayed color 60 self.color = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BACKGROUND) 59 61 #data 60 62 self._data = self.get_datalist() … … 169 171 children = ctrl.GetChildren() 170 172 if len(children) > 0: 171 ctrl.GetChildren()[0].SetBackGroundColour(\ 172 self.GetBackGroundColour()) 173 ctrl.GetChildren()[0].SetBackGroundColour(self.color) 173 174 else: 174 175 if not ctrl.IsEnabled(): … … 201 202 text = name 202 203 state_list = self.get_datalist().values() 203 if text in [str(state.data.name) for state in state_list]: 204 name_list = [] 205 for state in state_list: 206 if state.data == None: 207 theory_list = state.get_theory() 208 theory, _ = theory_list.values()[0] 209 d_name = str(theory.name) 210 else: 211 d_name = str(state.data.name) 212 name_list.append(d_name) 213 if text in name_list: 204 214 self._set_textctrl_color(self.data_namectr, 'pink') 205 215 msg = "DataOperation: The name already exists." … … 300 310 if data == None: 301 311 content = "?" 302 self.put_text_pic(self.data2_pic, content) 312 self.put_text_pic(self.data2_pic, content) 313 #item.SetClientData(pos, content) 303 314 else: 304 315 self.data2_pic.add_image(data) 305 else: 306 if data == None: 307 content = str(self.numberctr.GetValue().strip()) 308 try: 309 content = float(content) 310 data = content 311 except: 312 self._set_textctrl_color(self.numberctr, 'pink') 313 content = "?" 314 data = None 315 item.SetClientData(pos, content) 316 self.check_data_inputs() 317 else: 318 content = str(self.numberctr.GetValue().strip()) 319 try: 320 content = float(content) 321 data = content 322 except: 323 self._set_textctrl_color(self.numberctr, 'pink') 324 content = "?" 325 data = None 326 item.SetClientData(pos, data) 327 if data != None: 328 self.check_data_inputs() 329 316 330 self.put_text_pic(self.data2_pic, content) 317 self.check_data_inputs() 318 331 319 332 if self.output != None: 320 333 self.output.name = str(self.data_namectr.GetValue()) … … 350 363 self._set_textctrl_color(self.numberctr, 'white') 351 364 else: 352 self._set_textctrl_color(self.numberctr, 353 self.GetBackgroundColour()) 365 self._set_textctrl_color(self.numberctr, self.color ) 354 366 try: 355 367 float(data2) … … 369 381 elif data1.__class__.__name__ != data2.__class__.__name__: 370 382 self._set_textctrl_color(self.data1_cbox, 'pink') 371 self._set_textctrl_color(self.data 1_cbox, 'pink')383 self._set_textctrl_color(self.data2_cbox, 'pink') 372 384 msg = "DataOperation: Data types must be same." 373 385 self.send_warnings(msg, 'error') … … 393 405 pos = self.operator_cbox.GetCurrentSelection() 394 406 operator = self.operator_cbox.GetClientData(pos) 395 exec "output = data1 %s data2"% operator 407 try: 408 exec "output = data1 %s data2"% operator 409 except: 410 raise 396 411 return output 397 412 … … 479 494 self.data1_cbox.Clear() 480 495 self.data2_cbox.Clear() 496 481 497 if not self._data: 482 498 pos = self.data1_cbox.Append('No Data Available') … … 486 502 self.data2_cbox.SetSelection(pos2) 487 503 self.data2_cbox.SetClientData(pos2, None) 488 pos3 = self.data2_cbox.Append("Number")489 val = None490 if (self.numberctr.IsShown() and self.numberctr.IsEnabled()):491 try:492 val = float(self.numberctr.GetValue())493 except:494 val = None495 self.data2_cbox.SetClientData(pos3, val)496 504 return 497 505 pos1 = self.data1_cbox.Append('Select Data') … … 510 518 self.data2_cbox.SetClientData(pos3, val) 511 519 dnames = [] 512 for dstate in self._data.values(): 513 if dstate != None: 514 if dstate.data != None: 515 dnames.append(dstate.data.name) 516 if len(dnames) > 0: 517 ind = numpy.argsort(dnames) 518 for datastate in numpy.array(self._data.values())[ind]: 520 ids = self._data.keys() 521 for id in ids: 522 if id != None: 523 if self._data[id].data != None: 524 dnames.append(self._data[id].data.name) 525 else: 526 theory_list = self._data[id].get_theory() 527 theory, _ = theory_list.values()[0] 528 dnames.append(theory.name) 529 ind = numpy.argsort(dnames) 530 if len(ind) > 0: 531 val_list = numpy.array(self._data.values())[ind] 532 for datastate in val_list: 519 533 data = datastate.data 520 534 if data != None: … … 562 576 state_list = self.get_datalist().values() 563 577 name = self.data_namectr.GetValue().strip() 564 if name in [str(state.data.name) for state in state_list]: 578 name_list = [] 579 for state in state_list: 580 if state.data == None: 581 theory_list = state.get_theory() 582 theory, _ = theory_list.values()[0] 583 d_name = str(theory.name) 584 else: 585 d_name = str(state.data.name) 586 name_list.append(d_name) 587 if name in name_list: 565 588 self._set_textctrl_color(self.data_namectr, 'pink') 566 589 msg = "The Output Data Name already exists... " … … 674 697 pass 675 698 self.subplot.figure.canvas.resizing = False 676 self.subplot.set_xticks([ ])677 self.subplot.set_yticks([ ])699 self.subplot.set_xticks([0.0]) 700 self.subplot.set_yticks([0.0]) 678 701 # Draw zero axis lines 679 702 self.subplot.axhline(linewidth = 1, color='r')
Note: See TracChangeset
for help on using the changeset viewer.