Changeset 225aca8 in sasview for src/sas/guiframe
- Timestamp:
- Jul 28, 2015 12:14:38 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:
- a910c788
- Parents:
- ae2a197 (diff), d06c34c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- src/sas/guiframe
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/guiframe/gui_manager.py
r957af0d r225aca8 235 235 Initialize the Frame object 236 236 """ 237 238 237 PARENT_FRAME.__init__(self, parent=parent, title=title, pos=pos, size=size) 239 238 # title … … 364 363 frame.SetIcon(icon) 365 364 except: 366 pass365 logging.error("ViewerFrame.put_icon: could not set icon") 367 366 368 367 def get_client_size(self): … … 752 751 self._toolbar.Realize() 753 752 754 755 753 def build_gui(self): 756 754 """ … … 778 776 # Append item from plugin under menu file if necessary 779 777 self._populate_file_menu() 780 781 778 782 779 if not wx.VERSION_STRING >= '3.0.0.0': … … 822 819 # Load panels 823 820 self._load_panels() 824 self.set_default_perspective()825 821 826 822 def SetStatusText(self, *args, **kwds): … … 931 927 if hasattr(module, "PLUGIN_ID"): 932 928 try: 933 plug = module.Plugin() 934 if plug.set_default_perspective(): 935 self._current_perspective = plug 936 plugins.append(plug) 937 929 plugins.append(module.Plugin()) 938 930 msg = "Found plug-in: %s" % module.PLUGIN_ID 939 931 logging.info(msg) … … 1511 1503 for item in plugin.populate_file_menu(): 1512 1504 m_name, m_hint, m_handler = item 1513 id = wx.NewId()1514 self._file_menu.Append( id, m_name, m_hint)1515 wx.EVT_MENU(self, id, m_handler)1505 wx_id = wx.NewId() 1506 self._file_menu.Append(wx_id, m_name, m_hint) 1507 wx.EVT_MENU(self, wx_id, m_handler) 1516 1508 self._file_menu.AppendSeparator() 1517 1509 1518 1510 style1 = self.__gui_style & GUIFRAME.MULTIPLE_APPLICATIONS 1519 1511 if OPEN_SAVE_MENU: 1520 id = wx.NewId()1512 wx_id = wx.NewId() 1521 1513 hint_load_file = "read all analysis states saved previously" 1522 self._save_appl_menu = self._file_menu.Append( id, '&Open Project', hint_load_file)1523 wx.EVT_MENU(self, id, self._on_open_state_project)1514 self._save_appl_menu = self._file_menu.Append(wx_id, '&Open Project', hint_load_file) 1515 wx.EVT_MENU(self, wx_id, self._on_open_state_project) 1524 1516 1525 1517 if style1 == GUIFRAME.MULTIPLE_APPLICATIONS: … … 1527 1519 hint_load_file = "Read a status files and load" 1528 1520 hint_load_file += " them into the analysis" 1529 id = wx.NewId()1530 self._save_appl_menu = self._file_menu.Append( id,1521 wx_id = wx.NewId() 1522 self._save_appl_menu = self._file_menu.Append(wx_id, 1531 1523 '&Open Analysis', hint_load_file) 1532 wx.EVT_MENU(self, id, self._on_open_state_application)1524 wx.EVT_MENU(self, wx_id, self._on_open_state_application) 1533 1525 if OPEN_SAVE_MENU: 1534 1526 self._file_menu.AppendSeparator() 1535 id = wx.NewId()1536 self._file_menu.Append( id, '&Save Project',1527 wx_id = wx.NewId() 1528 self._file_menu.Append(wx_id, '&Save Project', 1537 1529 'Save the state of the whole analysis') 1538 wx.EVT_MENU(self, id, self._on_save_project)1530 wx.EVT_MENU(self, wx_id, self._on_save_project) 1539 1531 if style1 == GUIFRAME.MULTIPLE_APPLICATIONS: 1540 id = wx.NewId()1541 self._save_appl_menu = self._file_menu.Append( id, \1532 wx_id = wx.NewId() 1533 self._save_appl_menu = self._file_menu.Append(wx_id, \ 1542 1534 '&Save Analysis', 'Save state of the current active analysis panel') 1543 wx.EVT_MENU(self, id, self._on_save_application)1535 wx.EVT_MENU(self, wx_id, self._on_save_application) 1544 1536 if not sys.platform == 'darwin': 1545 1537 self._file_menu.AppendSeparator() 1546 id = wx.NewId()1547 self._file_menu.Append( id, '&Quit', 'Exit')1548 wx.EVT_MENU(self, id, self.Close)1538 wx_id = wx.NewId() 1539 self._file_menu.Append(wx_id, '&Quit', 'Exit') 1540 wx.EVT_MENU(self, wx_id, self.Close) 1549 1541 1550 1542 def _add_menu_file(self): … … 1717 1709 """ 1718 1710 """ 1719 message = ""1720 1711 log_msg = '' 1721 output = []1722 error_message = ""1723 1712 basename = os.path.basename(path) 1724 root, extension = os.path.splitext(basename)1713 _, extension = os.path.splitext(basename) 1725 1714 if extension.lower() not in EXTENSIONS: 1726 1715 log_msg = "File Loader cannot " … … 2224 2213 if hasattr(item, "post_init"): 2225 2214 item.post_init() 2226 2227 def set_default_perspective(self):2228 """2229 Choose among the plugin the first plug-in that has2230 "set_default_perspective" method and its return value is True will be2231 as a default perspective when the welcome page is closed2232 """2233 for item in self.plugins:2234 if hasattr(item, "set_default_perspective"):2235 if item.set_default_perspective():2236 item.on_perspective(event=None)2237 return2238 2215 2239 2216 def set_perspective(self, panels): … … 2414 2391 total_plot_list.append(theory_data) 2415 2392 for new_plot in total_plot_list: 2416 id = new_plot.id2417 2393 for group_id in new_plot.list_group_id: 2418 wx.PostEvent(self, NewPlotEvent(id= id,2394 wx.PostEvent(self, NewPlotEvent(id=new_plot.id, 2419 2395 group_id=group_id, 2420 2396 action='remove')) 2421 2397 #remove res plot: Todo: improve 2422 wx.CallAfter(self._remove_res_plot, id)2398 wx.CallAfter(self._remove_res_plot, new_plot.id) 2423 2399 self._data_manager.delete_data(data_id=data_id, 2424 2400 theory_id=theory_id) … … 2455 2431 ext_num = dlg.GetFilterIndex() 2456 2432 if ext_num == 0: 2457 format = '.txt'2433 ext_format = '.txt' 2458 2434 else: 2459 format = '.xml'2460 path = os.path.splitext(path)[0] + format2435 ext_format = '.xml' 2436 path = os.path.splitext(path)[0] + ext_format 2461 2437 mypath = os.path.basename(path) 2462 2438 2463 2439 #Instantiate a loader 2464 2440 loader = Loader() 2465 format = ".txt"2466 if os.path.splitext(mypath)[1].lower() == format:2441 ext_format = ".txt" 2442 if os.path.splitext(mypath)[1].lower() == ext_format: 2467 2443 # Make sure the ext included in the file name 2468 2444 # especially on MAC 2469 fName = os.path.splitext(path)[0] + format2445 fName = os.path.splitext(path)[0] + ext_format 2470 2446 self._onsaveTXT(data, fName) 2471 format = ".xml"2472 if os.path.splitext(mypath)[1].lower() == format:2447 ext_format = ".xml" 2448 if os.path.splitext(mypath)[1].lower() == ext_format: 2473 2449 # Make sure the ext included in the file name 2474 2450 # especially on MAC 2475 fName = os.path.splitext(path)[0] + format2476 loader.save(fName, data, format)2451 fName = os.path.splitext(path)[0] + ext_format 2452 loader.save(fName, data, ext_format) 2477 2453 try: 2478 2454 self._default_save_location = os.path.dirname(path) … … 2598 2574 ext_num = dlg.GetFilterIndex() 2599 2575 if ext_num == 0: 2600 format = '.dat'2576 ext_format = '.dat' 2601 2577 else: 2602 format = ''2603 path = os.path.splitext(path)[0] + format2578 ext_format = '' 2579 path = os.path.splitext(path)[0] + ext_format 2604 2580 mypath = os.path.basename(path) 2605 2581 … … 2607 2583 loader = Loader() 2608 2584 2609 format = ".dat"2610 if os.path.splitext(mypath)[1].lower() == format:2585 ext_format = ".dat" 2586 if os.path.splitext(mypath)[1].lower() == ext_format: 2611 2587 # Make sure the ext included in the file name 2612 2588 # especially on MAC 2613 fileName = os.path.splitext(path)[0] + format2614 loader.save(fileName, data, format)2589 fileName = os.path.splitext(path)[0] + ext_format 2590 loader.save(fileName, data, ext_format) 2615 2591 try: 2616 2592 self._default_save_location = os.path.dirname(path) … … 3206 3182 3207 3183 3208 class ViewApp(wx.App):3184 class SasViewApp(wx.App): 3209 3185 """ 3210 Toy application to test this Frame3186 SasView application 3211 3187 """ 3212 3188 def OnInit(self): … … 3294 3270 if len(os.listdir(model_folder)) > 0: 3295 3271 try: 3296 for file in os.listdir(model_folder):3297 file_path = os.path.join(model_folder, file )3272 for filename in os.listdir(model_folder): 3273 file_path = os.path.join(model_folder, filename) 3298 3274 if os.path.isfile(file_path): 3299 3275 os.remove(file_path) … … 3314 3290 """ 3315 3291 #try to load file at the start 3316 try: 3317 self.open_file() 3318 except: 3319 raise 3292 self.open_file() 3320 3293 self.frame.build_gui() 3321 3294 -
src/sas/guiframe/local_perspectives/data_loader/data_loader.py
rf76bf17 rf21d496 41 41 class Plugin(PluginBase): 42 42 43 def __init__(self , standalone=False):44 PluginBase.__init__(self, name="DataLoader" , standalone=standalone)43 def __init__(self): 44 PluginBase.__init__(self, name="DataLoader") 45 45 # Default location 46 46 self._default_save_location = DEFAULT_OPEN_FOLDER -
src/sas/guiframe/local_perspectives/plotting/plotting.py
rc039589 rf21d496 36 36 """ 37 37 38 def __init__(self , standalone=False):39 PluginBase.__init__(self, name="Plotting" , standalone=standalone)38 def __init__(self): 39 PluginBase.__init__(self, name="Plotting") 40 40 41 41 ## Plot panels -
src/sas/guiframe/plugin_base.py
r373d4ee rf21d496 34 34 """ 35 35 36 def __init__(self, name="Test_plugin" , standalone=True):36 def __init__(self, name="Test_plugin"): 37 37 """ 38 38 Abstract class for gui_manager Plugins. … … 42 42 ## Plug-in name. It will appear on the application menu. 43 43 self.sub_menu = name 44 #standalone flag45 self.standalone = standalone46 44 ## Reference to the parent window. Filled by get_panels() below. 47 45 self.parent = None … … 263 261 pass 264 262 265 def set_default_perspective(self):266 """267 Call back method that True to notify the parent that the current plug-in268 can be set as default perspective.269 when returning False, the plug-in is not candidate for an automatic270 default perspective setting271 """272 if self.standalone:273 return True274 return False275 276 263 def set_state(self, state=None, datainfo=None): 277 264 """ -
src/sas/guiframe/config.py
r5846bb5 r9989a6a 10 10 __build__ = '1' 11 11 __download_page__ = 'https://github.com/SasView/sasview/releases' 12 __update_URL__ = ['raw.githubusercontent.com', 13 '/SasView/sasview/master/sasview.latestversion'] 12 __update_URL__ = 'http://www.sasview.org/latestversion.json' 14 13 15 14 -
src/sas/guiframe/data_processor.py
re54dbc3e r44d20af 1 1 """ 2 Implement grid used to store data 2 Implement grid used to store results of a batch fit. 3 4 This is in Guiframe rather than fitting which is probably where it should be. 5 Actually could be a generic framework implemented in fit gui module. At this 6 point however there this grid behaves independently of the fitting panel and 7 only knows about information sent to it but not about the fits or fit panel and 8 thus cannot feed back to the fitting panel. This could change in the future. 9 10 The organization of the classes goes as: 11 12 .. image:: ../../user/guiframe/BatchGridClassLayout.png 13 :align: center 14 3 15 """ 4 16 import wx … … 26 38 """ 27 39 Object describing a cell in the grid. 28 29 40 """ 30 41 def __init__(self): 42 """ 43 Initialize attributes of class (label, value, col, row, object) 44 """ 31 45 self.label = "" 32 46 self.value = None … … 39 53 """ 40 54 Return a dictionary of column label and index or row selected 55 41 56 :param sentence: String to parse 42 57 :param list: list of columns label 58 :returns: col_dict 43 59 """ 60 44 61 p2 = re.compile(r'\d+') 45 62 p = re.compile(r'[\+\-\*\%\/]') … … 81 98 82 99 class SPanel(ScrolledPanel): 100 """ 101 ensure proper scrolling of GridPanel 102 103 Adds a SetupScrolling call to the normal ScrolledPanel init. 104 GridPanel then subclasses this class 105 106 """ 83 107 def __init__(self, parent, *args, **kwds): 108 """ 109 initialize ScrolledPanel then force a call to SetupScrolling 110 111 """ 84 112 ScrolledPanel.__init__(self, parent, *args, **kwds) 85 113 self.SetupScrolling() … … 87 115 88 116 class GridCellEditor(sheet.CCellEditor): 89 """ Custom cell editor """ 117 """ 118 Custom cell editor 119 120 This subclasses the sheet.CCellEditor (itself a subclass of 121 grid.GridCellEditor) in order to override two of its methods: 122 PaintBackrgound and EndEdit. 123 124 This is necessary as the sheet module is broken in wx 3.0.2 and 125 improperly subclasses grid.GridCellEditor 126 """ 90 127 def __init__(self, grid): 128 """ 129 Override of CCellEditor init. Runs the grid.GridCellEditor init code 130 """ 91 131 super(GridCellEditor, self).__init__(grid) 92 132 133 def PaintBackground(self, dc, rect, attr): 134 """ 135 Overrides wx.sheet.CCellEditor.PaintBackground which incorrectly calls 136 the base class method. 137 138 In wx3.0 all paint objects must explicitly 139 have a wxPaintDC (Device Context) object. Thus the paint event which 140 generates a call to this method provides such a DC object and the 141 base class in grid expects to receive that object. sheet was apparently 142 not updated to reflect this and hence fails. This could thus 143 become obsolete in a future bug fix of wxPython. 144 145 Apart from adding a dc variable in the list of arguments in the def 146 and in the call to the base class the rest of this method is copied 147 as is from sheet.CCellEditor.PaintBackground 148 149 **From original GridCellEditor docs:** 150 151 Draws the part of the cell not occupied by the edit control. The 152 base class version just fills it with background colour from the 153 attribute. 154 155 NOTE: There is no need to override this if you don't need 156 to do something out of the ordinary. 157 158 :param dc: the wxDC object for the paint 159 """ 160 # Call base class method. 161 DC = dc 162 super(sheet.CCellEditor,self).PaintBackground(DC, rect, attr) 163 93 164 def EndEdit(self, row, col, grid, previous): 94 """ 95 Commit editing the current cell. Returns True if the value has changed. 96 @param previous: previous value in the cell 165 """ 166 Commit editing the current cell. Returns True if the value has changed. 167 168 :param previous: previous value in the cell 97 169 """ 98 170 changed = False # Assume value not changed … … 108 180 class GridPage(sheet.CSheet): 109 181 """ 182 Class that receives the results of a batch fit. 183 184 GridPage displays the received results in a wx.grid using sheet. This is 185 then used by GridPanel and GridFrame to present the full GUI. 110 186 """ 111 187 def __init__(self, parent, panel=None): 112 188 """ 189 Initialize 190 191 Initialize all the attributes of GridPage, and the events. include 192 the init stuff from sheet.CSheet as well. 113 193 """ 114 194 #sheet.CSheet.__init__(self, parent) 115 195 116 196 # The following is the __init__ from CSheet. ########################## 117 197 # We re-write it here because the class is broken in wx 3.0, … … 139 219 140 220 # Sink events 221 self.Bind(wx.grid.EVT_GRID_RANGE_SELECT, self.OnRangeSelect) 222 self.Bind(wx.grid.EVT_GRID_ROW_SIZE, self.OnRowSize) 223 self.Bind(wx.grid.EVT_GRID_COL_SIZE, self.OnColSize) 224 self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnGridSelectCell) 225 # NOTE: the following bind to standard sheet methods that are 226 # overriden in this subclassn - actually we have currently 227 # disabled the on_context_menu that would override the OnRightClick 228 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnCellChange) 141 229 self.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnLeftClick) 142 230 self.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, self.OnRightClick) 143 231 #self.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.OnLeftDoubleClick) 144 self.Bind(wx.grid.EVT_GRID_RANGE_SELECT, self.OnRangeSelect)145 self.Bind(wx.grid.EVT_GRID_ROW_SIZE, self.OnRowSize)146 self.Bind(wx.grid.EVT_GRID_COL_SIZE, self.OnColSize)147 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnCellChange)148 self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnGridSelectCell)149 232 # This ends the __init__ section for CSheet. ########################## 233 234 235 236 # The following events must be bound even if CSheet is working 237 # properly and does not need the above re-implementation of the 238 # CSheet init method. Basically these override any intrinsic binding 239 self.Bind(wx.grid.EVT_GRID_LABEL_RIGHT_CLICK, self.on_right_click) 240 self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_CLICK, self.on_left_click) 150 241 151 242 self.AdjustScrollbars() … … 187 278 if self.GetNumberCols() > 0: 188 279 self.default_col_width = self.GetColSize(0) 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 282 # appropriate 189 283 #self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_CLICK, self.on_left_click) 190 284 #self.Bind(wx.grid.EVT_GRID_LABEL_RIGHT_CLICK, self.on_right_click) … … 194 288 195 289 def OnLeftClick(self, event): 290 """ 291 Overrides sheet.CSheet.OnLefClick. 292 293 Processes when a cell is selected by left clicking on that cell. First 294 process the base Sheet method then the current class specific method 295 """ 196 296 sheet.CSheet.OnLeftClick(self, event) 197 297 self.on_selected_cell(event) 198 199 def on_edit_cell(self, event): 200 """ 298 299 300 def OnCellChange(self, event): 301 """ 302 Overrides sheet.CSheet.OnCellChange. 303 304 Processes when a cell has been edited by a cell editor. Checks for the 305 edited row being outside the max row to use attribute and if so updates 306 the last row. Then calls the base handler using skip. 201 307 """ 202 308 row, _ = event.GetRow(), event.GetCol() … … 209 315 def on_selected_cell(self, event): 210 316 """ 211 Handler catching cell selection 212 """ 317 Handler catching cell selection. 318 319 Called after calling base 'on left click' method. 320 """ 321 213 322 flag = event.CmdDown() or event.ControlDown() 214 323 flag_shift = event.ShiftDown() … … 280 389 def on_left_click(self, event): 281 390 """ 282 Catch the left click on label mouse event 283 """ 391 Is triggered when the left mouse button is clicked while the mouse 392 is hovering over the column 'label.' 393 394 This processes the information on the selected column: the column name 395 (in row 0 of column) and the range of cells with a valid value to be 396 used by the GridPanel set_axis methods. 397 """ 398 284 399 flag = event.CmdDown() or event.ControlDown() 285 400 … … 324 439 def on_right_click(self, event): 325 440 """ 326 Catch the right click mouse 327 """ 441 Is triggered when the right mouse button is clicked while the mouse 442 is hovering over the column 'label.' 443 444 This brings up a context menu that allows the deletion of the column, 445 or the insertion of a new column either to the right or left of the 446 current column. If inserting a new column can insert a blank column or 447 choose a number of hidden columns. By default all the error parameters 448 are in hidden columns so as to save space on the grid. Also any other 449 intrinsic variables stored with the data such as Temperature, pressure, 450 time etc can be used to populate this menu. 451 """ 452 328 453 col = event.GetCol() 329 454 row = event.GetRow() … … 360 485 def insert_col_menu(self, menu, label, window): 361 486 """ 362 """ 487 method called to populate the 'insert column before current column' 488 submenu. 489 """ 490 363 491 if self.data is None: 364 492 return … … 380 508 def insert_after_col_menu(self, menu, label, window): 381 509 """ 382 """ 510 Method called to populate the 'insert column after current column' 511 submenu 512 """ 513 383 514 if self.data is None: 384 515 return … … 401 532 def on_remove_column(self, event=None): 402 533 """ 403 """ 534 Called when user chooses remove from the column right click menu 535 Checks the columnn exists then calls the remove_column method 536 """ 537 404 538 if self.selected_cols is not None or len(self.selected_cols) > 0: 405 539 col = self.selected_cols[0] … … 408 542 def remove_column(self, col, numCols=1): 409 543 """ 410 Remove column to the current grid 411 """ 544 Remove the col column from the current grid 545 """ 546 412 547 # add data to the grid 413 548 row = 0 … … 429 564 def on_insert_column(self, event): 430 565 """ 431 """ 566 Called when user chooses insert 'column before' submenu 567 of the column context menu obtained when right clicking on a given 568 column header. 569 570 Sets up to insert column into the current grid before the current 571 highlighted column location and sets up what to populate that column 572 with. Then calls insert_column method to actually do the insertion. 573 """ 574 432 575 if self.selected_cols is not None or len(self.selected_cols) > 0: 433 576 col = self.selected_cols[0] … … 442 585 def on_insert_after_column(self, event): 443 586 """ 444 Insert the given column after the highlighted column 445 """ 587 Called when user chooses insert 'column after' submenu 588 of the column context menu obtained when right clicking on a given 589 column header. 590 591 Sets up to insert column into the current grid after the current 592 highlighted column location and sets up what to populate that column 593 with. Then calls insert_column method to actually do the insertion. 594 """ 595 446 596 if self.selected_cols is not None or len(self.selected_cols) > 0: 447 597 col = self.selected_cols[0] + 1 … … 455 605 def insert_column(self, col, col_name): 456 606 """ 457 """ 607 Insert column at position col with data[col_name] into the current 608 grid. 609 """ 610 458 611 row = 0 459 612 self.InsertCols(pos=col, numCols=1, updateLabels=True) … … 477 630 def on_set_x_axis(self, event): 478 631 """ 479 """ 632 Just calls the panel version of the method 633 """ 634 480 635 self.panel.set_xaxis(x=self.axis_value, label=self.axis_label) 481 636 482 637 def on_set_y_axis(self, event): 483 638 """ 484 """ 639 Just calls the panel version of the method 640 """ 641 485 642 self.panel.set_yaxis(y=self.axis_value, label=self.axis_label) 486 643 … … 488 645 """ 489 646 Add data to the grid 647 490 648 :param data_inputs: data to use from the context menu of the grid 491 :param data_ouputs: default columns deplayed 492 """ 649 :param data_ouputs: default columns displayed 650 """ 651 493 652 self.file_name = file_name 494 653 self.details = details … … 527 686 Set the values in grids 528 687 """ 688 529 689 # add data to the grid 530 690 row = 0 … … 562 722 Return value contained in the grid 563 723 """ 724 564 725 grid_view = {} 565 726 for col in xrange(self.GetNumberCols()): … … 584 745 def onContextMenu(self, event): 585 746 """ 586 Default context menu 587 """ 747 Method to handle cell right click context menu. 748 749 THIS METHOD IS NOT CURRENTLY USED. It is designed to provide a 750 cell pop up context by right clicking on a cell and gives the 751 option to cut, paste, and clear. This will probably be removed in 752 future versions and is being superceded by more traditional cut and 753 paste options. 754 """ 755 588 756 wx_id = wx.NewId() 589 757 c_menu = wx.Menu() … … 620 788 def on_copy(self, event): 621 789 """ 622 On copy event from the contextmenu 623 """ 790 Called when copy is chosen from cell right click context menu 791 792 THIS METHOD IS NOT CURRENTLY USED. it is part of right click cell 793 context menu which is being removed. This will probably be removed in 794 future versions and is being superceded by more traditional cut and 795 paste options 796 """ 797 624 798 self.Copy() 625 799 626 800 def on_paste(self, event): 627 801 """ 628 On paste event from the contextmenu 629 """ 802 Called when paste is chosen from cell right click context menu 803 804 THIS METHOD IS NOT CURRENTLY USED. it is part of right click cell 805 context menu which is being removed. This will probably be removed in 806 future versions and is being superceded by more traditional cut and 807 paste options 808 """ 809 630 810 if self.data == None: 631 811 self.data = {} … … 636 816 def on_clear(self, event): 637 817 """ 638 Clear the cells selected 639 """ 818 Called when clear cell is chosen from cell right click context menu 819 820 THIS METHOD IS NOT CURRENTLY USED. it is part of right click cell 821 context menu which is being removed. This will probably be removed in 822 future versions and is being superceded by more traditional cut and 823 paste options 824 """ 825 640 826 self.Clear() 641 827 … … 646 832 ## Title to appear on top of the window 647 833 """ 834 648 835 window_caption = "Notebook " 649 836 … … 682 869 def enable_close_button(self): 683 870 """ 684 display the close button on tab for more than 1 tabs else remove the 685 close button 686 """ 871 display the close button on the tab if more than 1 tab exits. 872 Otherwise remove the close button 873 """ 874 687 875 if self.GetPageCount() <= 1: 688 876 style = self.GetWindowStyleFlag() … … 700 888 def on_edit_axis(self): 701 889 """ 702 Return the select cell of a given selected column. Check that all cells 703 are from the same column 704 """ 890 Return the select cell range from a given selected column. Checks that 891 all cells are from the same column 892 """ 893 705 894 pos = self.GetSelection() 706 895 grid = self.GetPage(pos) … … 732 921 Add highlight rows 733 922 """ 923 734 924 pos = self.GetSelection() 735 925 grid = self.GetPage(pos) … … 759 949 def get_column_labels(self): 760 950 """ 761 return dictionary of columns labels of the current page 762 """ 951 return dictionary of columns labels on the current page 952 """ 953 763 954 pos = self.GetSelection() 764 955 grid = self.GetPage(pos) … … 773 964 """ 774 965 Receive a list of cells and create a string presenting the selected 775 cells. 966 cells that can be used as data for one axis of a plot. 967 776 968 :param cell_list: list of tuple 777 778 969 """ 779 970 pos = self.GetSelection() … … 853 1044 close the page 854 1045 """ 1046 855 1047 if self.GetPageCount() == 1: 856 1048 event.Veto() … … 858 1050 859 1051 def set_data(self, data_inputs, data_outputs, details="", file_name=None): 1052 """ 1053 """ 860 1054 if data_outputs is None or data_outputs == {}: 861 1055 return … … 880 1074 def get_odered_results(self, inputs, outputs=None): 881 1075 """ 882 Get ordered the results 883 """ 1076 Order a list of 'inputs.' Used to sort rows and columns to present 1077 in batch results grid. 1078 """ 1079 884 1080 # Let's re-order the data from the keys in 'Data' name. 885 1081 if outputs == None: … … 914 1110 Append a new column to the grid 915 1111 """ 1112 1113 # I Believe this is no longer used now that we have removed the 1114 # edit menu from the menubar - PDB July 12, 2015 916 1115 pos = self.GetSelection() 917 1116 grid = self.GetPage(pos) … … 922 1121 Remove the selected column from the grid 923 1122 """ 1123 # I Believe this is no longer used now that we have removed the 1124 # edit menu from the menubar - PDB July 12, 2015 924 1125 pos = self.GetSelection() 925 1126 grid = self.GetPage(pos) … … 927 1128 928 1129 class GridPanel(SPanel): 1130 """ 1131 A ScrolledPanel class that contains the grid sheet as well as a number of 1132 widgets to create interesting plots and buttons for help etc. 1133 """ 1134 929 1135 def __init__(self, parent, data_inputs=None, 930 1136 data_outputs=None, *args, **kwds): 1137 """ 1138 Initialize the GridPanel 1139 """ 1140 931 1141 SPanel.__init__(self, parent, *args, **kwds) 932 1142 … … 990 1200 def get_plot_axis(self, col, list): 991 1201 """ 992 993 1202 """ 994 1203 axis = [] … … 1015 1224 def on_view(self, event): 1016 1225 """ 1017 Get object represented buy the given cell and plot them. 1018 """ 1226 Get object represented by the given cells and plot them. Basically 1227 plot the colum in y vs the column in x. 1228 """ 1229 1019 1230 pos = self.notebook.GetSelection() 1020 1231 grid = self.notebook.GetPage(pos) … … 1096 1307 Evaluate the contains of textcrtl and plot result 1097 1308 """ 1309 1098 1310 pos = self.notebook.GetSelection() 1099 1311 grid = self.notebook.GetPage(pos) … … 1203 1415 running "file:///...." 1204 1416 1205 :param evt: Triggers on clicking the help button 1206 """ 1417 :param evt: Triggers on clicking the help button 1418 """ 1419 1207 1420 #import documentation window here to avoid circular imports 1208 1421 #if put at top of file with rest of imports. … … 1218 1431 Get sentence from dict 1219 1432 """ 1433 1220 1434 for tok, (col_name, list) in dict.iteritems(): 1221 1435 col = column_names[col_name] … … 1230 1444 def layout_grid(self): 1231 1445 """ 1232 Draw the area related to the grid 1233 """ 1446 Draw the area related to the grid by adding it as the first element 1447 in the panel's grid_sizer 1448 """ 1449 1234 1450 self.notebook = Notebook(parent=self) 1235 1451 self.notebook.set_data(self._data_inputs, self._data_outputs) … … 1238 1454 def layout_plotting_area(self): 1239 1455 """ 1240 Draw area containing options to plot 1241 """ 1456 Add the area containing all the plot options, buttons etc to a plotting 1457 area sizer to later be added to the top level grid_sizer 1458 """ 1459 1242 1460 view_description = wx.StaticBox(self, -1, 'Plot Fits/Residuals') 1243 1461 note = "To plot the fits (or residuals), click the 'View Fits' button" … … 1281 1499 (self.plot_button, 0, 1282 1500 wx.LEFT | wx.TOP | wx.BOTTOM, 12), 1283 (self.help_button,0, 1501 (self.help_button,0, 1284 1502 wx.LEFT | wx.TOP | wx.BOTTOM, 12)]) 1285 1503 … … 1316 1534 Get the selected column on the visible grid and set values for axis 1317 1535 """ 1536 1318 1537 try: 1319 1538 cell_list = self.notebook.on_edit_axis() … … 1335 1554 Receive a list of cells and create a string presenting the selected 1336 1555 cells. 1556 1337 1557 :param cell_list: list of tuple 1338 1339 """ 1558 """ 1559 1340 1560 if self.notebook is not None: 1341 1561 return self.notebook.create_axis_label(cell_list) … … 1345 1565 get controls to modify 1346 1566 """ 1567 1347 1568 if label != None: 1348 1569 tcrtl_label.SetValue(str(label)) … … 1353 1574 """ 1354 1575 """ 1576 # I Believe this is no longer used now that we have removed the 1577 # edit menu from the menubar - PDB July 12, 2015 1355 1578 if self.notebook is not None: 1356 1579 self.notebook.add_column() … … 1359 1582 """ 1360 1583 """ 1584 # I Believe this is no longer used now that we have removed the 1585 # edit menu from the menubar - PDB July 12, 2015 1361 1586 if self.notebook is not None: 1362 1587 self.notebook.on_remove_column() … … 1364 1589 1365 1590 class GridFrame(wx.Frame): 1591 """ 1592 The main wx.Frame for the batch results grid 1593 """ 1594 1366 1595 def __init__(self, parent=None, data_inputs=None, data_outputs=None, id=-1, 1367 title="Grid Window", size=(800, 500)): 1596 title="Batch Fitting Results Panel", size=(800, 500)): 1597 """ 1598 Initialize the Frame 1599 """ 1600 1368 1601 wx.Frame.__init__(self, parent=parent, id=id, title=title, size=size) 1369 1602 self.parent = parent … … 1389 1622 wx.EVT_MENU(self, self.save_menu.GetId(), self.on_save_page) 1390 1623 1391 # To add the edit menu, call add_edit_menu() here. 1392 self.edit = None 1624 # We need to grab a WxMenu handle here, otherwise the next one to grab 1625 # the handle will be treated as the Edit Menu handle when checking in 1626 # on_menu_open event handler and thus raise an exception when it hits an 1627 # unitialized object. Alternative is to comment out that whole section 1628 # in on_menu_open, but that would make it more difficult to undo the 1629 # hidding of the menu. PDB July 12, 2015. 1630 # 1631 # To enable the Edit menubar comment out next line and uncomment the 1632 # following line. 1633 self.edit = wx.Menu() 1634 #self.add_edit_menu() 1635 1393 1636 self.Bind(wx.EVT_MENU_OPEN, self.on_menu_open) 1394 1395 1637 self.Bind(wx.EVT_CLOSE, self.on_close) 1396 1638 1397 1639 def add_edit_menu(self, menubar): 1640 """ 1641 populates the edit menu on the menubar. Not activated as of SasView 1642 3.1.0 1643 """ 1398 1644 self.edit = wx.Menu() 1399 1645 … … 1429 1675 def on_copy(self, event): 1430 1676 """ 1431 On Copy 1432 """ 1677 On Copy from the Edit menu item on the menubar 1678 """ 1679 # I Believe this is no longer used now that we have removed the 1680 # edit menu from the menubar - PDB July 12, 2015 1433 1681 if event != None: 1434 1682 event.Skip() … … 1439 1687 def on_paste(self, event): 1440 1688 """ 1441 On Paste 1442 """ 1689 On Paste from the Edit menu item on the menubar 1690 """ 1691 # I Believe this is no longer used now that we have removed the 1692 # edit menu from the menubar - PDB July 12, 2015 1443 1693 if event != None: 1444 1694 event.Skip() … … 1449 1699 def on_clear(self, event): 1450 1700 """ 1451 On Clear 1452 """ 1701 On Clear from the Edit menu item on the menubar 1702 """ 1703 # I Believe this is no longer used now that we have removed the 1704 # edit menu from the menubar - PDB July 12, 2015 1453 1705 pos = self.panel.notebook.GetSelection() 1454 1706 grid = self.panel.notebook.GetPage(pos) … … 1466 1718 def on_remove_column(self, event): 1467 1719 """ 1468 On remove column 1469 """ 1720 On remove column from the Edit menu Item on the menubar 1721 """ 1722 # I Believe this is no longer used now that we have removed the 1723 # edit menu from the menubar - PDB July 12, 2015 1470 1724 pos = self.panel.notebook.GetSelection() 1471 1725 grid = self.panel.notebook.GetPage(pos) … … 1535 1789 def on_save_page(self, event): 1536 1790 """ 1537 """ 1791 Saves data in grid to a csv file. 1792 1793 At this time only the columns displayed get saved. Thus any error 1794 bars not inserted before saving will not be saved in the file 1795 """ 1796 1538 1797 if self.parent is not None: 1539 1798 pos = self.panel.notebook.GetSelection() … … 1566 1825 def on_open(self, event): 1567 1826 """ 1568 Open file containg batch result 1569 """ 1827 Open file containing batch result 1828 """ 1829 1570 1830 if self.parent is not None: 1571 1831 self.parent.on_read_batch_tofile(self) … … 1575 1835 open excel and display batch result in Excel 1576 1836 """ 1837 1577 1838 if self.parent is not None: 1578 1839 pos = self.panel.notebook.GetSelection() … … 1625 1886 details="", *args, **kwds): 1626 1887 """ 1888 Initialize dialog 1889 1627 1890 :param parent: Window instantiating this dialog 1628 :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\ 1629 1892 application. 1630 1893 """ 1894 1631 1895 #kwds['style'] = wx.CAPTION|wx.SYSTEM_MENU 1632 1896 wx.Frame.__init__(self, parent, *args, **kwds) … … 1651 1915 Draw the content of the current dialog window 1652 1916 """ 1917 1653 1918 vbox = wx.BoxSizer(wx.VERTICAL) 1654 1919 box_description = wx.StaticBox(self.panel, -1, str("Batch Outputs")) … … 1704 1969 Get the user selection and display output to the selected application 1705 1970 """ 1971 1706 1972 if self.flag == 1: 1707 1973 self.parent.open_with_localapp(data_inputs=self.data_inputs, … … 1715 1981 close the Window 1716 1982 """ 1983 1717 1984 self.Close() 1718 1985 … … 1721 1988 Receive event and display data into third party application 1722 1989 or save data to file. 1723 1724 1990 """ 1725 1991 if self.save_to_file.GetValue(): -
src/sas/guiframe/documentation_window.py
r7a508b6 rfb3f9af 43 43 (self, parent, dummy_id, path, url_instruction, title, size=(850, 540)) 44 44 45 :param path: path to html file beginning AFTER /doc/ and ending in the 46 file.html 47 :param url_instructions: anchor string or other query e.g. '#MyAnchor 48 :param title -text to place in the title bar of the help panel45 :param path: path to html file beginning AFTER /doc/ and ending in the\ 46 file.html. 47 :param url_instructions: anchor string or other query e.g. '#MyAnchor' 48 :param title: text to place in the title bar of the help panel 49 49 """ 50 50 def __init__(self, parent, dummy_id, path, url_instruction, title, size=(850, 540)): -
src/sas/guiframe/local_perspectives/plotting/Plotter1D.py
rb99a4552 r098f3d2 564 564 self._slicerpop.Append(wx_id, '&Print Image', 'Print image ') 565 565 wx.EVT_MENU(self, wx_id, self.onPrint) 566 wx_id = wx.NewId()567 self._slicerpop.Append(wx_id, '&Print Preview', 'Print preview')568 wx.EVT_MENU(self, wx_id, self.onPrinterPreview)569 566 570 567 wx_id = wx.NewId() -
src/sas/guiframe/local_perspectives/plotting/Plotter2D.py
rc039589 r098f3d2 300 300 301 301 wx_id = wx.NewId() 302 slicerpop.Append(wx_id, '&Print Preview', 'Print preview')303 wx.EVT_MENU(self, wx_id, self.onPrinterPreview)304 305 wx_id = wx.NewId()306 302 slicerpop.Append(wx_id, '&Copy to Clipboard', 'Copy to the clipboard') 307 303 wx.EVT_MENU(self, wx_id, self.OnCopyFigureMenu) -
src/sas/guiframe/local_perspectives/plotting/SimplePlot.py
rb40ad40 r098f3d2 58 58 slicerpop.Append(wx_id, '&Print Image', 'Print image') 59 59 wx.EVT_MENU(self, wx_id, self.onPrint) 60 61 wx_id = wx.NewId()62 slicerpop.Append(wx_id, '&Print Preview', 'Print preview')63 wx.EVT_MENU(self, wx_id, self.onPrinterPreview)64 60 65 61 wx_id = wx.NewId() … … 234 230 wx.EVT_MENU(self, id, self.on_print_image) 235 231 236 id = wx.NewId()237 item = wx.MenuItem(menu, id, "&Print Preview")238 item.SetBitmap(preview_bmp)239 menu.AppendItem(item)240 wx.EVT_MENU(self, id, self.on_print_preview)241 242 232 menu.AppendSeparator() 243 233 id = wx.NewId() -
src/sas/guiframe/report_dialog.py
re8bb5b6 r098f3d2 66 66 hbox.Add(button_close) 67 67 button_close.SetFocus() 68 69 button_preview = wx.Button(self, wx.NewId(), "Preview")70 button_preview.SetToolTipString("Print preview this report.")71 button_preview.Bind(wx.EVT_BUTTON, self.onPreview,72 id=button_preview.GetId())73 hbox.Add(button_preview)74 68 75 69 button_print = wx.Button(self, wx.NewId(), "Print")
Note: See TracChangeset
for help on using the changeset viewer.