Changeset 86a9e6c in sasview
- Timestamp:
- Jul 6, 2012 6:02:05 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:
- 88a65e2
- Parents:
- c71d042
- Location:
- sansguiframe/src/sans/guiframe
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sansguiframe/src/sans/guiframe/data_processor.py
rc71d042 r86a9e6c 126 126 self.SetNumberRows(self._rows) 127 127 self.SetNumberCols(self._cols) 128 color = self.parent.GetBackgroundColour() 129 for col in range(self._cols): 130 self.SetCellBackgroundColour(0, col, color) 128 131 self.AutoSize() 129 132 self.list_plot_panels = {} … … 216 219 if cell_row > 0 and cell_row < self.max_row_touse: 217 220 self.axis_value.append(self.GetCellValue(cell_row, cell_col)) 218 221 219 222 def on_left_click(self, event): 220 223 """ … … 226 229 col = event.GetCol() 227 230 row = event.GetRow() 231 228 232 if not (flag): 229 233 self.selected_cols = [] … … 422 426 if width < self.default_col_width: 423 427 self.SetColSize(col, self.default_col_width) 428 color = self.parent.GetBackgroundColour() 429 self.SetCellBackgroundColour(0, col, color) 424 430 self.ForceRefresh() 425 431 … … 529 535 return grid_view 530 536 537 def get_nofrows(self): 538 """ 539 Return number of total rows 540 """ 541 return self._rows 542 531 543 class Notebook(nb, PanelBase): 532 544 """ … … 546 558 wx.CLIP_CHILDREN) 547 559 PanelBase.__init__(self, parent) 560 self.gpage_num = 1 548 561 self.enable_close_button() 549 562 self.parent = parent … … 552 565 #add empty page 553 566 self.add_empty_page() 554 555 self.Bind( wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.on_close_page)567 self.pageClosedEvent = wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE 568 self.Bind(self.pageClosedEvent, self.on_close_page) 556 569 557 570 def add_empty_page(self): … … 561 574 self.AddPage(grid, "", True) 562 575 pos = self.GetPageIndex(grid) 563 title = "Grid" + str(self. GetPageCount())576 title = "Grid" + str(self.gpage_num) 564 577 self.SetPageText(pos, title) 565 578 self.SetSelection(pos) 579 self.enable_close_button() 580 self.gpage_num += 1 566 581 return grid , pos 567 582 … … 605 620 msg += "Please select elements of the same col.\n" 606 621 raise ValueError, msg 622 623 # Finally check the highlighted cell if any cells missing 624 self.get_highlighted_row() 607 625 else: 608 626 msg = "No item selected.\n" 609 627 msg += "Please select only one column or one cell" 610 628 raise ValueError, msg 611 612 629 return grid.selected_cells 613 630 614 631 def get_highlighted_row(self): 632 """ 633 Add highlight rows 634 """ 635 pos = self.GetSelection() 636 grid = self.GetPage(pos) 637 col = grid.selected_cols[0] 638 # Finally check the highlighted cell if any cells missing 639 for row in range(grid.get_nofrows()): 640 if grid.IsInSelection(row, col): 641 cel = (row, col) 642 if row < 1: 643 continue 644 if not grid.GetCellValue(row, col): 645 continue 646 if cel not in grid.selected_cells: 647 grid.selected_cells.append(cel) 648 615 649 def get_column_labels(self): 616 650 """ … … 655 689 if len(cell_list) > 0: 656 690 if len(cell_list) == 1: 657 row_min, col = cell_list[0] 658 col_name = grid.GetColLabelValue(int(col))#grid.GetCellValue(0, col) 659 col_title = grid.GetCellValue(0, col) 660 label = create_label(col_name, row_min+1 , row_min+1) 661 return label, col_title 691 row_min, col = cell_list[0] 692 col_name = grid.GetColLabelValue(int(col)) 693 694 col_title = grid.GetCellValue(0, col) 695 label = create_label(col_name, row_min+1 , row_min+1) 696 return label, col_title 662 697 else: 663 698 temp_list = copy.deepcopy(cell_list) … … 666 701 row_min, col = temp_list[0] 667 702 row_max, _ = temp_list[length-1] 668 col_name = grid.GetColLabelValue(int(col))#grid.GetCellValue(0, col)703 col_name = grid.GetColLabelValue(int(col)) 669 704 col_title = grid.GetCellValue(0, col) 705 670 706 index = 0 671 for row in xrange(row_min, row_max + 1):707 for row in xrange(row_min, row_max + 1): 672 708 if index > 0 and index < len(temp_list): 673 709 new_row, _ = temp_list[index] … … 676 712 if index -1 >= 0: 677 713 new_row, _ = temp_list[index-1] 678 if not new_row==None and new_row!=' ' : 679 label += create_label(col_name, None, int(new_row) +1) 714 if not new_row == None and new_row != ' ' : 715 label += create_label(col_name, None, 716 int(new_row) +1) 680 717 else: 681 718 label += "]" … … 684 721 new_row, _ = temp_list[index + 1] 685 722 if not new_row==None: 686 label += create_label(col_name, int(new_row)+1, None) 723 label += create_label(col_name, 724 int(new_row)+1, None) 687 725 if row_min != None and row_max != None: 688 726 if index == 0: 689 label += create_label(col_name, int(row_min)+1, None) 727 label += create_label(col_name, 728 int(row_min)+1, None) 690 729 elif index == len(temp_list)-1: 691 label += create_label(col_name, None, int(row_max)+1) 730 label += create_label(col_name, None, 731 int(row_max)+1) 692 732 index += 1 693 733 # clean up the list 694 734 label_out = '' 695 735 for item in label.split(','): 696 if item.split(":")[1] =="]":736 if item.split(":")[1] == "]": 697 737 continue 698 738 else: … … 707 747 if self.GetPageCount() == 1: 708 748 event.Veto() 709 self.enable_close_button()749 wx.CallAfter(self.enable_close_button) 710 750 711 751 def set_data(self, data_inputs, data_outputs, details="", file_name=None): … … 806 846 self.plot_button = None 807 847 self.notebook = None 848 self.plot_num = 1 808 849 809 850 self.layout_grid() … … 869 910 grid = self.notebook.GetPage(pos) 870 911 title = self.notebook.GetPageText(pos) 912 self.notebook.get_highlighted_row() 871 913 if len(grid.selected_cells) == 0: 872 914 msg = "Highlight a Data or Chi2 column first..." … … 937 979 #time.sleep(0.5) 938 980 return 939 #continue 940 """ 941 wx.PostEvent(self.parent.parent, 942 NewPlotEvent(action="clear", 943 group_id=str(group_id), 944 title=title)) 945 """ 981 946 982 wx.PostEvent(self.parent.parent, 947 983 NewPlotEvent(plot=new_plot, … … 963 999 #continue 964 1000 965 966 967 968 1001 def on_plot(self, event): 969 1002 """ … … 982 1015 raise ValueError, msg 983 1016 except: 984 wx.PostEvent(self.parent.parent,985 StatusEvent(status=msg, info="error"))986 return987 1017 msg = "X axis value error." 1018 wx.PostEvent(self.parent.parent, 1019 StatusEvent(status=msg, info="error")) 1020 return 988 1021 dict = parse_string(sentence, column_names.keys()) 989 sentence = self.get_sentence(dict, sentence, column_names)1022 990 1023 try: 1024 sentence = self.get_sentence(dict, sentence, column_names) 991 1025 x = eval(sentence) 992 1026 except: … … 997 1031 #evaluate y 998 1032 sentence = self.y_axis_label.GetValue() 999 if sentence.strip() == "": 1000 msg = "select value for y axis" 1001 raise ValueError, msg 1033 try: 1034 if sentence.strip() == "": 1035 msg = "select value for y axis" 1036 raise ValueError, msg 1037 except: 1038 msg = "Y axis value error." 1039 wx.PostEvent(self.parent.parent, 1040 StatusEvent(status=msg, info="error")) 1041 return 1002 1042 dict = parse_string(sentence, column_names.keys()) 1003 sentence = self.get_sentence(dict, sentence, column_names)1004 1043 try: 1044 sentence = self.get_sentence(dict, sentence, column_names) 1005 1045 y = eval(sentence) 1006 1046 except: … … 1052 1092 try: 1053 1093 title = y_title.strip() 1054 title += self.notebook.GetPageText(pos) 1094 1095 title += "_" + self.notebook.GetPageText(pos) 1096 title += "_" + str(self.plot_num) 1097 self.plot_num += 1 1055 1098 new_plot.name = title 1056 1099 new_plot.xtransform = "x" … … 1346 1389 """ 1347 1390 if self.parent is not None: 1348 self.parent.on_read_batch_tofile( event)1391 self.parent.on_read_batch_tofile(self) 1349 1392 1350 1393 def open_with_excel(self, event): -
sansguiframe/src/sans/guiframe/gui_manager.py
rd560a37 r86a9e6c 374 374 self.show_batch_frame(None) 375 375 376 def on_read_batch_tofile(self, event):376 def on_read_batch_tofile(self, base): 377 377 """ 378 378 Open a file dialog , extract the file to read and display values … … 382 382 if self._default_save_location == None: 383 383 self._default_save_location = os.getcwd() 384 385 dlg = wx.FileDialog( self,384 wildcard = "(*.csv; *.txt)|*.csv; *.txt" 385 dlg = wx.FileDialog(base, 386 386 "Choose a file", 387 387 self._default_save_location, "", 388 "(*.csv)|*.csv| Text Files (*.txt)|*.txt")388 wildcard) 389 389 if dlg.ShowModal() == wx.ID_OK: 390 390 path = dlg.GetPath() … … 392 392 self._default_save_location = os.path.dirname(path) 393 393 dlg.Destroy() 394 self.read_batch_tofile(file_name=path) 395 394 try: 395 self.read_batch_tofile(file_name=path) 396 except: 397 msg = "Error occurred when reading the file; %s\n"% path 398 msg += "%s\n"% sys.exc_value 399 wx.PostEvent(self, StatusEvent(status=msg, 400 info="error")) 401 396 402 def read_batch_tofile(self, file_name): 397 403 """ … … 446 452 c_name = col_name_toks[col_index] 447 453 if c_name.strip() != "": 448 data[c_name] = [ lines[row].split(separator)[c_index] 449 for row in range(index + 1, len(lines)-1)] 454 # distinguish between column name and value 455 try: 456 float(c_name) 457 col_name = "Column %s"% str(col_index + 1) 458 index_min = index 459 except: 460 col_name = c_name 461 index_min = index + 1 462 data[col_name] = [ lines[row].split(separator)[c_index] 463 for row in range(index_min, len(lines)-1)] 450 464 c_index += 1 451 465
Note: See TracChangeset
for help on using the changeset viewer.