- Timestamp:
- Jul 26, 2015 2:40:18 PM (9 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:
- c95a1a5
- Parents:
- 1d115ef
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/guiframe/data_processor.py
ra12c0a6 r44d20af 9 9 10 10 The organization of the classes goes as: 11 .. image:: media/BatchGridClassLayout.png 11 12 .. image:: ../../user/guiframe/BatchGridClassLayout.png 12 13 :align: center 13 14 … … 37 38 """ 38 39 Object describing a cell in the grid. 39 40 40 """ 41 41 def __init__(self): 42 42 """ 43 43 Initialize attributes of class (label, value, col, row, object) 44 45 44 """ 46 45 self.label = "" … … 54 53 """ 55 54 Return a dictionary of column label and index or row selected 56 55 57 56 :param sentence: String to parse 58 57 :param list: list of columns label 59 58 :returns: col_dict 60 59 """ 61 60 … … 116 115 117 116 class GridCellEditor(sheet.CCellEditor): 118 """ 117 """ 119 118 Custom cell editor 120 119 121 120 This subclasses the sheet.CCellEditor (itself a subclass of 122 121 grid.GridCellEditor) in order to override two of its methods: … … 125 124 This is necessary as the sheet module is broken in wx 3.0.2 and 126 125 improperly subclasses grid.GridCellEditor 127 128 126 """ 129 127 def __init__(self, grid): 130 128 """ 131 129 Override of CCellEditor init. Runs the grid.GridCellEditor init code 132 133 130 """ 134 131 super(GridCellEditor, self).__init__(grid) 135 132 136 133 def PaintBackground(self, dc, rect, attr): 137 """ 134 """ 138 135 Overrides wx.sheet.CCellEditor.PaintBackground which incorrectly calls 139 136 the base class method. 140 137 141 138 In wx3.0 all paint objects must explicitly 142 139 have a wxPaintDC (Device Context) object. Thus the paint event which … … 145 142 not updated to reflect this and hence fails. This could thus 146 143 become obsolete in a future bug fix of wxPython. 147 144 148 145 Apart from adding a dc variable in the list of arguments in the def 149 146 and in the call to the base class the rest of this method is copied 150 147 as is from sheet.CCellEditor.PaintBackground 151 152 :param dc: the wxDC object for the paint153 ------- 148 149 **From original GridCellEditor docs:** 150 154 151 Draws the part of the cell not occupied by the edit control. The 155 152 base class version just fills it with background colour from the … … 159 156 to do something out of the ordinary. 160 157 158 :param dc: the wxDC object for the paint 161 159 """ 162 160 # Call base class method. … … 165 163 166 164 def EndEdit(self, row, col, grid, previous): 167 """ 165 """ 168 166 Commit editing the current cell. Returns True if the value has changed. 169 167 170 168 :param previous: previous value in the cell 171 172 169 """ 173 170 changed = False # Assume value not changed … … 184 181 """ 185 182 Class that receives the results of a batch fit. 186 183 187 184 GridPage displays the received results in a wx.grid using sheet. This is 188 185 then used by GridPanel and GridFrame to present the full GUI. 189 190 186 """ 191 187 def __init__(self, parent, panel=None): 192 188 """ 193 189 Initialize 194 190 195 191 Initialize all the attributes of GridPage, and the events. include 196 192 the init stuff from sheet.CSheet as well. 197 198 193 """ 199 194 #sheet.CSheet.__init__(self, parent) 200 195 201 196 # The following is the __init__ from CSheet. ########################## 202 197 # We re-write it here because the class is broken in wx 3.0, … … 243 238 # CSheet init method. Basically these override any intrinsic binding 244 239 self.Bind(wx.grid.EVT_GRID_LABEL_RIGHT_CLICK, self.on_right_click) 245 self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_CLICK, self.on_left_click) 240 self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_CLICK, self.on_left_click) 246 241 247 242 self.AdjustScrollbars() … … 283 278 if self.GetNumberCols() > 0: 284 279 self.default_col_width = self.GetColSize(0) 285 # We have moved these to the top of the init section with the 286 # rest of the grid event bindings from the sheet init when 280 # We have moved these to the top of the init section with the 281 # rest of the grid event bindings from the sheet init when 287 282 # appropriate 288 283 #self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_CLICK, self.on_left_click) … … 295 290 """ 296 291 Overrides sheet.CSheet.OnLefClick. 297 292 298 293 Processes when a cell is selected by left clicking on that cell. First 299 294 process the base Sheet method then the current class specific method 300 301 295 """ 302 296 sheet.CSheet.OnLeftClick(self, event) 303 297 self.on_selected_cell(event) 304 298 305 299 306 300 def OnCellChange(self, event): 307 301 """ 308 302 Overrides sheet.CSheet.OnCellChange. 309 303 310 304 Processes when a cell has been edited by a cell editor. Checks for the 311 305 edited row being outside the max row to use attribute and if so updates 312 the last row. Then calls the base handler using skip. 313 306 the last row. Then calls the base handler using skip. 314 307 """ 315 308 row, _ = event.GetRow(), event.GetCol() … … 323 316 """ 324 317 Handler catching cell selection. 325 318 326 319 Called after calling base 'on left click' method. 327 328 320 """ 329 321 … … 398 390 """ 399 391 Is triggered when the left mouse button is clicked while the mouse 400 is hovering over the column 'label.' 401 392 is hovering over the column 'label.' 393 402 394 This processes the information on the selected column: the column name 403 395 (in row 0 of column) and the range of cells with a valid value to be 404 396 used by the GridPanel set_axis methods. 405 406 """ 407 397 """ 398 408 399 flag = event.CmdDown() or event.ControlDown() 409 400 … … 449 440 """ 450 441 Is triggered when the right mouse button is clicked while the mouse 451 is hovering over the column 'label.' 452 442 is hovering over the column 'label.' 443 453 444 This brings up a context menu that allows the deletion of the column, 454 or the insertion of a new column either to the right or left of the 445 or the insertion of a new column either to the right or left of the 455 446 current column. If inserting a new column can insert a blank column or 456 447 choose a number of hidden columns. By default all the error parameters … … 458 449 intrinsic variables stored with the data such as Temperature, pressure, 459 450 time etc can be used to populate this menu. 460 461 """ 462 451 """ 452 463 453 col = event.GetCol() 464 454 row = event.GetRow() … … 497 487 method called to populate the 'insert column before current column' 498 488 submenu. 499 500 """ 501 489 """ 490 502 491 if self.data is None: 503 492 return … … 521 510 Method called to populate the 'insert column after current column' 522 511 submenu 523 524 """ 525 512 """ 513 526 514 if self.data is None: 527 515 return … … 546 534 Called when user chooses remove from the column right click menu 547 535 Checks the columnn exists then calls the remove_column method 548 549 """ 550 536 """ 537 551 538 if self.selected_cols is not None or len(self.selected_cols) > 0: 552 539 col = self.selected_cols[0] … … 556 543 """ 557 544 Remove the col column from the current grid 558 559 """ 560 545 """ 546 561 547 # add data to the grid 562 548 row = 0 … … 581 567 of the column context menu obtained when right clicking on a given 582 568 column header. 583 569 584 570 Sets up to insert column into the current grid before the current 585 571 highlighted column location and sets up what to populate that column 586 572 with. Then calls insert_column method to actually do the insertion. 587 588 """ 589 573 """ 574 590 575 if self.selected_cols is not None or len(self.selected_cols) > 0: 591 576 col = self.selected_cols[0] … … 602 587 Called when user chooses insert 'column after' submenu 603 588 of the column context menu obtained when right clicking on a given 604 column header. 605 589 column header. 590 606 591 Sets up to insert column into the current grid after the current 607 592 highlighted column location and sets up what to populate that column 608 593 with. Then calls insert_column method to actually do the insertion. 609 610 """ 611 594 """ 595 612 596 if self.selected_cols is not None or len(self.selected_cols) > 0: 613 597 col = self.selected_cols[0] + 1 … … 623 607 Insert column at position col with data[col_name] into the current 624 608 grid. 625 626 """ 627 609 """ 610 628 611 row = 0 629 612 self.InsertCols(pos=col, numCols=1, updateLabels=True) … … 648 631 """ 649 632 Just calls the panel version of the method 650 651 """ 652 633 """ 634 653 635 self.panel.set_xaxis(x=self.axis_value, label=self.axis_label) 654 636 … … 656 638 """ 657 639 Just calls the panel version of the method 658 659 """ 640 """ 641 660 642 self.panel.set_yaxis(y=self.axis_value, label=self.axis_label) 661 643 … … 663 645 """ 664 646 Add data to the grid 665 647 666 648 :param data_inputs: data to use from the context menu of the grid 667 :param data_ouputs: default columns deplayed 668 669 """ 670 649 :param data_ouputs: default columns displayed 650 """ 651 671 652 self.file_name = file_name 672 653 self.details = details … … 704 685 """ 705 686 Set the values in grids 706 707 """ 708 687 """ 688 709 689 # add data to the grid 710 690 row = 0 … … 741 721 """ 742 722 Return value contained in the grid 743 744 """ 745 723 """ 724 746 725 grid_view = {} 747 726 for col in xrange(self.GetNumberCols()): … … 761 740 """ 762 741 Return number of total rows 763 764 742 """ 765 743 return self._rows … … 768 746 """ 769 747 Method to handle cell right click context menu. 770 748 771 749 THIS METHOD IS NOT CURRENTLY USED. It is designed to provide a 772 750 cell pop up context by right clicking on a cell and gives the … … 774 752 future versions and is being superceded by more traditional cut and 775 753 paste options. 776 777 """ 778 754 """ 755 779 756 wx_id = wx.NewId() 780 757 c_menu = wx.Menu() … … 817 794 future versions and is being superceded by more traditional cut and 818 795 paste options 819 820 796 """ 821 797 … … 825 801 """ 826 802 Called when paste is chosen from cell right click context menu 827 803 828 804 THIS METHOD IS NOT CURRENTLY USED. it is part of right click cell 829 805 context menu which is being removed. This will probably be removed in 830 806 future versions and is being superceded by more traditional cut and 831 807 paste options 832 833 808 """ 834 809 … … 847 822 future versions and is being superceded by more traditional cut and 848 823 paste options 849 850 824 """ 851 825 … … 857 831 window_name = "Fit panel" 858 832 ## Title to appear on top of the window 859 860 833 """ 861 834 862 835 window_caption = "Notebook " 863 836 … … 898 871 display the close button on the tab if more than 1 tab exits. 899 872 Otherwise remove the close button 900 901 873 """ 902 874 … … 918 890 Return the select cell range from a given selected column. Checks that 919 891 all cells are from the same column 920 921 892 """ 922 893 … … 949 920 """ 950 921 Add highlight rows 951 952 922 """ 953 923 … … 980 950 """ 981 951 return dictionary of columns labels on the current page 982 983 952 """ 984 953 … … 996 965 Receive a list of cells and create a string presenting the selected 997 966 cells that can be used as data for one axis of a plot. 998 967 999 968 :param cell_list: list of tuple 1000 1001 969 """ 1002 970 pos = self.GetSelection() … … 1075 1043 """ 1076 1044 close the page 1077 1078 1045 """ 1079 1046 … … 1109 1076 Order a list of 'inputs.' Used to sort rows and columns to present 1110 1077 in batch results grid. 1111 1112 1078 """ 1113 1079 … … 1143 1109 """ 1144 1110 Append a new column to the grid 1145 1146 1111 """ 1147 1112 … … 1155 1120 """ 1156 1121 Remove the selected column from the grid 1157 1158 1122 """ 1159 1123 # I Believe this is no longer used now that we have removed the … … 1166 1130 """ 1167 1131 A ScrolledPanel class that contains the grid sheet as well as a number of 1168 widgets to create interesting plots and buttons for help etc. 1169 1132 widgets to create interesting plots and buttons for help etc. 1170 1133 """ 1171 1134 … … 1174 1137 """ 1175 1138 Initialize the GridPanel 1176 1177 1139 """ 1178 1140 … … 1264 1226 Get object represented by the given cells and plot them. Basically 1265 1227 plot the colum in y vs the column in x. 1266 1267 1228 """ 1268 1229 … … 1345 1306 """ 1346 1307 Evaluate the contains of textcrtl and plot result 1347 1348 1308 """ 1349 1309 … … 1456 1416 1457 1417 :param evt: Triggers on clicking the help button 1458 1459 1418 """ 1460 1419 … … 1471 1430 """ 1472 1431 Get sentence from dict 1473 1474 1432 """ 1475 1433 … … 1488 1446 Draw the area related to the grid by adding it as the first element 1489 1447 in the panel's grid_sizer 1490 1491 1448 """ 1492 1449 … … 1499 1456 Add the area containing all the plot options, buttons etc to a plotting 1500 1457 area sizer to later be added to the top level grid_sizer 1501 1502 1458 """ 1503 1459 … … 1543 1499 (self.plot_button, 0, 1544 1500 wx.LEFT | wx.TOP | wx.BOTTOM, 12), 1545 (self.help_button,0, 1501 (self.help_button,0, 1546 1502 wx.LEFT | wx.TOP | wx.BOTTOM, 12)]) 1547 1503 … … 1577 1533 """ 1578 1534 Get the selected column on the visible grid and set values for axis 1579 1580 1535 """ 1581 1536 … … 1601 1556 1602 1557 :param cell_list: list of tuple 1603 1604 1558 """ 1605 1559 … … 1610 1564 """ 1611 1565 get controls to modify 1612 1613 1566 """ 1614 1567 … … 1621 1574 """ 1622 1575 """ 1623 # I Believe this is no longer used now that we have removed the 1576 # I Believe this is no longer used now that we have removed the 1624 1577 # edit menu from the menubar - PDB July 12, 2015 1625 1578 if self.notebook is not None: … … 1629 1582 """ 1630 1583 """ 1631 # I Believe this is no longer used now that we have removed the 1584 # I Believe this is no longer used now that we have removed the 1632 1585 # edit menu from the menubar - PDB July 12, 2015 1633 1586 if self.notebook is not None: … … 1638 1591 """ 1639 1592 The main wx.Frame for the batch results grid 1640 1641 1593 """ 1642 1594 … … 1645 1597 """ 1646 1598 Initialize the Frame 1647 1648 1599 """ 1649 1600 … … 1690 1641 populates the edit menu on the menubar. Not activated as of SasView 1691 1642 3.1.0 1692 1693 1643 """ 1694 1644 self.edit = wx.Menu() … … 1725 1675 def on_copy(self, event): 1726 1676 """ 1727 On Copy from the Edit menu item on the menubar 1728 1677 On Copy from the Edit menu item on the menubar 1729 1678 """ 1730 1679 # I Believe this is no longer used now that we have removed the … … 1739 1688 """ 1740 1689 On Paste from the Edit menu item on the menubar 1741 1742 1690 """ 1743 1691 # I Believe this is no longer used now that we have removed the … … 1752 1700 """ 1753 1701 On Clear from the Edit menu item on the menubar 1754 1755 1702 """ 1756 1703 # I Believe this is no longer used now that we have removed the … … 1763 1710 """ 1764 1711 Get Label Text 1765 1766 1712 """ 1767 1713 for item in self.insert_before_menu.GetMenuItems(): … … 1773 1719 """ 1774 1720 On remove column from the Edit menu Item on the menubar 1775 1776 1721 """ 1777 1722 # I Believe this is no longer used now that we have removed the … … 1784 1729 """ 1785 1730 On menu open 1786 1787 1731 """ 1788 1732 if self.file == event.GetMenu(): … … 1846 1790 """ 1847 1791 Saves data in grid to a csv file. 1848 1792 1849 1793 At this time only the columns displayed get saved. Thus any error 1850 1794 bars not inserted before saving will not be saved in the file 1851 1852 1795 """ 1853 1796 … … 1883 1826 """ 1884 1827 Open file containing batch result 1885 1886 1828 """ 1887 1829 … … 1892 1834 """ 1893 1835 open excel and display batch result in Excel 1894 1895 1836 """ 1896 1837 … … 1919 1860 """ 1920 1861 Append a new column to the grid 1921 1922 1862 """ 1923 1863 self.panel.add_column() … … 1926 1866 """ 1927 1867 Set data 1928 1929 1868 """ 1930 1869 self.panel.notebook.set_data(data_inputs=data_inputs, … … 1936 1875 """ 1937 1876 Add a new table 1938 1939 1877 """ 1940 1878 # DO not event.Skip(): it will make 2 pages … … 1944 1882 """ 1945 1883 Allow to select where the result of batch will be displayed or stored 1946 1947 1884 """ 1948 1885 def __init__(self, parent, data_inputs, data_outputs, file_name="", … … 1952 1889 1953 1890 :param parent: Window instantiating this dialog 1954 :param result: result to display in a grid or export to an external 1891 :param result: result to display in a grid or export to an external\ 1955 1892 application. 1956 1957 1893 """ 1958 1894 … … 1978 1914 """ 1979 1915 Draw the content of the current dialog window 1980 1981 1916 """ 1982 1917 … … 2033 1968 """ 2034 1969 Get the user selection and display output to the selected application 2035 2036 1970 """ 2037 1971 … … 2046 1980 """ 2047 1981 close the Window 2048 2049 1982 """ 2050 1983 … … 2055 1988 Receive event and display data into third party application 2056 1989 or save data to file. 2057 2058 1990 """ 2059 1991 if self.save_to_file.GetValue():
Note: See TracChangeset
for help on using the changeset viewer.