Changeset 7ad194fa in sasview for sansguiframe/src
- Timestamp:
- Sep 6, 2011 5:04:48 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:
- 55bb249c
- Parents:
- edcb00bd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansguiframe/src/sans/guiframe/data_processor.py
r49ad00b r7ad194fa 5 5 import numpy 6 6 import sys 7 import copy 7 8 from wx.lib.scrolledpanel import ScrolledPanel 8 9 import wx.grid as Grid … … 44 45 self.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.on_selected_cell) 45 46 46 47 47 def on_selected_cell(self, event): 48 48 """ … … 95 95 self.PopupMenu(slicerpop, pos) 96 96 97 98 97 def on_set_x_axis(self, event): 99 98 """ … … 113 112 data = {} 114 113 if len(data) > 0: 115 116 114 self._cols = self.GetNumberCols() 117 115 self._rows = self.GetNumberRows() … … 154 152 """ 155 153 nb.__init__(self, parent, -1, 156 style= wx.aui.AUI_BUTTON_DOWN|wx.aui.AUI_NB_WINDOWLIST_BUTTON| 154 style= wx.aui.AUI_BUTTON_DOWN| 155 wx.aui.AUI_NB_WINDOWLIST_BUTTON| 157 156 wx.aui.AUI_NB_DEFAULT_STYLE| 158 157 wx.CLIP_CHILDREN) … … 163 162 self.data = data 164 163 self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.on_close_page) 165 166 164 167 165 def enable_close_button(self): 168 166 """ … … 196 194 if len(grid.selected_cols) == 1: 197 195 col = grid.selected_cols[0] 196 if len(grid.selected_cells) > 0: 197 cell_row, cell_col = grid.selected_cells[0] 198 if cell_col != col: 199 msg = "Edit axis doesn't understand this selection.\n" 200 msg += "Please select element of the same col" 201 raise ValueError, msg 198 202 for row in range(grid.GetNumberRows()): 199 list_of_cells.append((row, col)) 200 201 print "selected cell", grid.selected_cells.sort(), grid.selected_cells 202 203 203 list_of_cells.append((row + 1 , col)) 204 for item in grid.selected_cells: 205 if item in list_of_cells: 206 list_of_cells.remove(item) 207 elif len(grid.selected_cols) == 0: 208 list_of_cells = [(row + 1, col) for row, col in grid.selected_cells] 209 return list_of_cells 210 211 def create_axis_label(self, cell_list): 212 """ 213 Receive a list of cells and create a string presenting the selected 214 cells. 215 :param cell_list: list of tuple 216 217 """ 218 pos = self.GetSelection() 219 grid = self.GetPage(pos) 220 label = "" 221 col_name = "" 222 if len(cell_list) > 0: 223 temp_list = copy.deepcopy(cell_list) 224 temp_list.sort() 225 temp = [] 226 for item in temp_list: 227 if item[0] <= 1: 228 temp.append(item) 229 for element in temp: 230 temp_list.remove(element) 231 row_min, _ = temp_list[0] 232 row_max = row_min 233 label += str(col_name) + "[" + str(row_min) + ":" 234 print "temp_list", temp_list 235 for index in xrange(len(temp_list)): 236 prev = index - 1 237 row, _ = temp_list[index] 238 if row > row_max + 1 : 239 if prev > 0: 240 row_max, _ = temp_list[prev] 241 label += str(row_max) + "]" + "," 242 row_min = row 243 label += "[" + str(row_min) + ":" 244 row_max = row 245 246 if (index == len(temp_list)- 1): 247 label += str(row_max) + "]" 248 print "here" 249 print "label ", label 250 return label 251 204 252 def on_close_page(self, event): 205 253 """ … … 210 258 self.enable_close_button() 211 259 212 213 214 260 def set_data(self, data): 215 261 if data is None: … … 254 300 255 301 self.plotting_sizer = wx.FlexGridSizer(3, 7, 10, 5) 256 w, h = self.GetSize()257 #self.panel_grid = SPanel(self, -1, size=(w, -1))258 302 self.grid_sizer = wx.BoxSizer(wx.HORIZONTAL) 259 303 self.vbox.AddMany([(self.grid_sizer, 1, wx.EXPAND, 0), … … 264 308 self.x = [] 265 309 self.y = [] 266 267 310 self.x_axis_label = None 268 311 self.y_axis_label = None … … 297 340 self.y_axis_label.SetValue(str(label)) 298 341 299 300 301 342 def on_plot(self, event): 302 343 """ … … 319 360 self.grid.set_data(self._data) 320 361 self.grid_sizer.Add(self.grid, 1, wx.EXPAND, 0) 321 322 323 def layout_grid1(self):324 """325 Draw the area related to the grid326 """327 self.grid = Table(parent=self.panel_grid, data=self._data)328 vbox = wx.BoxSizer(wx.HORIZONTAL)329 vbox.Add(self.grid, 1, wx.EXPAND, 0)330 self.panel_grid.SetSizer(vbox)331 362 332 363 def layout_plotting_area(self): … … 375 406 Get the selected column on the visible grid and set values for axis 376 407 """ 377 self.grid.on_edit_axis() 378 408 cell_list = self.grid.on_edit_axis() 409 self.create_axis_label(cell_list) 410 411 def create_axis_label(self, cell_list): 412 """ 413 Receive a list of cells and create a string presenting the selected 414 cells. 415 :param cell_list: list of tuple 416 417 """ 418 if self.grid is not None: 419 return self.grid.create_axis_label(cell_list) 420 379 421 def edit_axis_helper(self, tcrtl_label, tcrtl_value): 380 422 """ … … 394 436 395 437 class GridFrame(wx.Frame): 396 def __init__(self, parent=None, data=None, id=-1, title="Batch Results", size=(700, 400)): 438 def __init__(self, parent=None, data=None, id=-1, 439 title="Batch Results", size=(700, 400)): 397 440 wx.Frame.__init__(self, parent=parent, id=id, title=title, size=size) 398 441 self.parent = parent
Note: See TracChangeset
for help on using the changeset viewer.