Changeset 8523a1f2 in sasview
- Timestamp:
- Sep 12, 2011 4:38:17 PM (13 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:
- c911f34
- Parents:
- 33dd2e5
- Location:
- sansguiframe/src/sans/guiframe
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sansguiframe/src/sans/guiframe/data_processor.py
r83eb1b52 r8523a1f2 22 22 FUNC_DICT = {"sqrt": "math.sqrt", 23 23 "pow": "math.sqrt"} 24 25 24 26 25 … … 74 73 self.panel = panel 75 74 self.col_names = [] 75 self.data_inputs = {} 76 self.data_outputs = {} 76 77 self._cols = 50 77 78 self._rows = 51 … … 164 165 self.panel.set_yaxis(y=self.axis_value, label=self.axis_label) 165 166 166 def set_data(self, data ):167 def set_data(self, data_inputs, data_outputs): 167 168 """ 168 169 Add data to the grid 169 170 """ 170 if data is None: 171 data = {} 172 if len(data) > 0: 171 if data_outputs is None: 172 data_outputs = {} 173 self.data_outputs = data_outputs 174 if self.data_inputs is None: 175 data_inputs = {} 176 self.data_inputs = data_inputs 177 178 if len(self.data_outputs) > 0: 173 179 self._cols = self.GetNumberCols() 174 180 self._rows = self.GetNumberRows() 175 self.data = data 176 self.col_names = data.keys() 181 self.col_names = self.data_outputs.keys() 177 182 self.col_names.sort() 178 183 nbr_user_cols = len(self.col_names) … … 182 187 self.AppendCols(new_col_nbr, True) 183 188 #Add more rows to the grid if necessary 184 nbr_user_row = len(self.data .values())189 nbr_user_row = len(self.data_outputs.values()) 185 190 if nbr_user_row > self._rows + 1: 186 191 new_row_nbr = nbr_user_row - self._rows … … 188 193 # add data to the grid 189 194 row = 0 190 for index in range(nbr_user_cols): 191 col = index 195 col = 0 196 cell_col = 0 197 for col_name in self.col_names: 192 198 # use the first row of the grid to add user defined labels 193 self.SetCellValue(row, col, str(self.col_names[index])) 194 col = 0 195 for value_list in self.data.values(): 196 row = 1 197 for index in range(len(value_list)): 198 self.SetCellValue(row, col, str(value_list[index])) 199 row += 1 199 self.SetCellValue(row, col, str(col_name)) 200 200 col += 1 201 cell_row = 1 202 value_list = self.data_outputs[col_name] 203 204 for value in value_list: 205 self.SetCellValue(cell_row, cell_col, str(value)) 206 cell_row += 1 207 cell_col += 1 201 208 self.AutoSize() 202 209 … … 331 338 self.enable_close_button() 332 339 333 def set_data(self, data ):334 if data is None:340 def set_data(self, data_inputs, data_outputs): 341 if data_outputs is None or data_outputs == {}: 335 342 return 336 337 343 grid = GridPage(self, panel=self.parent) 338 grid.set_data(data )344 grid.set_data(data_inputs, data_outputs) 339 345 self.AddPage(grid, "") 340 346 pos = self.GetPageIndex(grid) … … 368 374 369 375 class GridPanel(SPanel): 370 def __init__(self, parent, data=None, *args, **kwds): 376 def __init__(self, parent, data_inputs=None, 377 data_outputs=None, *args, **kwds): 371 378 SPanel.__init__(self, parent , *args, **kwds) 372 379 self.vbox = wx.BoxSizer(wx.VERTICAL) … … 378 385 (self.plotting_sizer)]) 379 386 self.parent = parent 380 self._data = data 387 self._data_inputs = data_inputs 388 self._data_outputs = data_outputs 381 389 self.x = [] 382 390 self.y = [] … … 393 401 self.SetSizer(self.vbox) 394 402 395 def set_data(self, data ):403 def set_data(self, data_inputs, data_outputs): 396 404 """ 397 405 """ 398 406 if self.notebook is not None: 399 self.notebook.set_data(data )407 self.notebook.set_data(data_inputs, data_outputs) 400 408 401 409 def set_xaxis(self, label="", x=None): … … 488 496 """ 489 497 self.notebook = Notebook(parent=self) 490 self.notebook.set_data(self._data )498 self.notebook.set_data(self._data_inputs, self._data_outputs) 491 499 self.grid_sizer.Add(self.notebook, 1, wx.EXPAND, 0) 492 500 … … 582 590 583 591 class GridFrame(wx.Frame): 584 def __init__(self, parent=None, data =None, id=-1,592 def __init__(self, parent=None, data_inputs=None, data_outputs=None, id=-1, 585 593 title="Batch Results", size=(700, 400)): 586 594 wx.Frame.__init__(self, parent=parent, id=id, title=title, size=size) 587 595 self.parent = parent 588 self.panel = GridPanel(self, data )596 self.panel = GridPanel(self, data_inputs, data_outputs) 589 597 menubar = wx.MenuBar() 590 598 self.SetMenuBar(menubar) … … 616 624 self.panel.add_column() 617 625 618 def set_data(self, data ):619 """ 620 """ 621 self.panel.set_data(data )626 def set_data(self, data_inputs, data_outputs): 627 """ 628 """ 629 self.panel.set_data(data_inputs, data_outputs) 622 630 623 631 … … 626 634 Allow to select where the result of batch will be displayed or stored 627 635 """ 628 def __init__(self, parent, data =None, file_name="",636 def __init__(self, parent, data_inputs, data_outputs, file_name="", 629 637 details="", *args, **kwds): 630 638 """ … … 639 647 self.file_name = file_name 640 648 self.details = details 641 self.data = data 649 self.data_inputs = data_inputs 650 self.data_outputs = data_outputs 651 self.data = {} 652 for item in (self.data_outputs, self.data_inputs): 653 self.data.update(item) 642 654 self.flag = 1 643 655 self.SetSize((300, 200)) … … 646 658 self.save_to_file = None 647 659 self._do_layout() 648 660 649 661 def _do_layout(self): 650 662 """ … … 710 722 """ 711 723 if self.flag == 1: 712 self.parent.open_with_localapp(self.data) 724 self.parent.open_with_localapp(data_inputs=self.data_inputs, 725 data_outputs=self.data_outputs) 713 726 elif self.flag == 2: 714 727 self.parent.open_with_externalapp(data=self.data, … … 762 775 data["index"+str(i)] = [i/j, i*j, i, i+j] 763 776 764 frame = GridFrame(data =data)777 frame = GridFrame(data_outputs=data, data_inputs=data) 765 778 frame.Show(True) 766 779 except: -
sansguiframe/src/sans/guiframe/gui_manager.py
rdc79cfc r8523a1f2 287 287 self.setup_custom_conf() 288 288 289 def on_set_batch_result(self, data, plugin_name): 289 def on_set_batch_result(self, data_outputs, data_inputs=None, 290 plugin_name=""): 290 291 """ 291 292 Display data into a grid in batch mode and show the grid … … 301 302 file_name = self._default_save_location + str(file_name) 302 303 #Need to save configuration for later 303 frame = BatchOutputFrame(parent=self, data=data, 304 frame = BatchOutputFrame(parent=self, data_outputs=data_outputs, 305 data_inputs=data_inputs, 304 306 file_name=file_name, 305 307 details=details) 306 308 frame.Show(True) 307 309 308 def open_with_localapp(self, data ):310 def open_with_localapp(self, data_inputs, data_outputs): 309 311 """ 310 312 Display value of data into the application grid 311 313 :param data: dictionary of string and list of items 312 314 """ 313 self.batch_frame.set_data(data )315 self.batch_frame.set_data(data_inputs, data_outputs) 314 316 self.batch_frame.Show(True) 315 317 … … 349 351 buffer = fd.read() 350 352 lines = buffer.split('\n') 353 fd.close() 351 354 column_names_line = "" 352 355 index = None
Note: See TracChangeset
for help on using the changeset viewer.