Changeset 9c8f3ad in sasview for sansguiframe/src
- Timestamp:
- Aug 30, 2011 4:42:30 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:
- 5eede4e
- Parents:
- cd61c4d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansguiframe/src/sans/guiframe/data_processor.py
r8c347a6 r9c8f3ad 18 18 19 19 class GridPage(sheet.CSheet): 20 """ 21 """ 20 22 def __init__(self, parent, panel=None): 21 23 """ … … 23 25 sheet.CSheet.__init__(self, parent) 24 26 self.SetLabelBackgroundColour('#DBD4D4') 27 self.AutoSize() 25 28 self.panel = panel 26 29 self.col_names = [] 27 self._cols = 0 28 self._rows = 0 30 self._cols = 50 31 self._rows = 51 32 col_with = 30 33 row_height = 20 34 self.SetColMinimalAcceptableWidth(col_with) 35 self.SetRowMinimalAcceptableHeight(row_height) 29 36 self.SetNumberRows(self._cols) 30 37 self.SetNumberCols(self._rows) … … 33 40 self.axis_label = "" 34 41 35 36 42 def on_right_click(self, event): 37 print "on double click", event.GetRow(), event.GetCol() 43 """ 44 Catch the right click mouse 45 """ 38 46 col = event.GetCol() 39 47 if col != -1 and len(self.col_names) > col: … … 49 57 wx.EVT_MENU(self, id, self.on_set_x_axis) 50 58 51 52 59 id = wx.NewId() 53 60 slicerpop.Append(id, '&Set Y axis', 'Set Y axis') … … 58 65 59 66 60 61 67 def on_set_x_axis(self, event): 68 """ 69 """ 62 70 self.panel.set_xaxis(x=self.axis_value, label=self.axis_label) 63 71 64 72 def on_set_y_axis(self, event): 73 """ 74 """ 65 75 self.panel.set_yaxis(y=self.axis_value, label=self.axis_label) 66 76 67 77 def set_data(self, data): 68 78 """ 79 Add data to the grid 69 80 """ 70 81 if data is None: 71 82 data = {} 72 83 if len(data) > 0: 84 85 self._cols = self.GetNumberCols() 86 self._rows = self.GetNumberRows() 73 87 self.data = data 74 88 self.col_names = data.keys() 75 89 self.col_names.sort() 76 self._cols = len(self.data.keys()) 77 self._rows = max([len(v) for v in self.data.values()]) 78 self.SetNumberRows(int(self._rows)) 79 self.SetNumberCols(int(self._cols)) 80 for index in range(len(self.col_names)): 81 self.SetColLabelValue(index, str(self.col_names[index])) 82 90 nbr_user_cols = len(self.col_names) 91 #Add more columns to the grid if necessary 92 if nbr_user_cols > self._cols: 93 new_col_nbr = nbr_user_cols - self._cols 94 self.AppendCols(new_col_nbr, True) 95 #Add more rows to the grid if necessary 96 nbr_user_row = len(self.data.values()) 97 if nbr_user_row > self._rows + 1: 98 new_row_nbr = nbr_user_row - self._rows 99 self.AppendRows(new_row_nbr, True) 100 # add data to the grid 101 label_row = 0 102 for index in range(nbr_user_cols): 103 # use the first row of the grid to add user defined labels 104 self.SetCellValue(label_row, index, str(self.col_names[index])) 83 105 col = 0 84 106 for value_list in self.data.values(): 85 for row in range( len(value_list)):107 for row in range(1, len(value_list)): 86 108 self.SetCellValue(row, col, str(value_list[row])) 87 109 col += 1 88 110 self.AutoSize() 111 89 112 90 113 class Notebook(nb, PanelBase): … … 100 123 """ 101 124 nb.__init__(self, parent, -1, 102 style= wx.NB_BOTTOM) 125 style= wx.aui.AUI_BUTTON_DOWN|wx.aui.AUI_NB_WINDOWLIST_BUTTON| 126 wx.aui.AUI_NB_DEFAULT_STYLE| 127 wx.CLIP_CHILDREN) 103 128 PanelBase.__init__(self, parent) 104 129 self.enable_close_button() 105 130 self.parent = parent 106 131 self.manager = manager 107 132 self.data = data 108 133 self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.on_close_page) 134 135 def enable_close_button(self): 136 """ 137 display the close button on tab for more than 1 tabs else remove the 138 close button 139 """ 140 if self.GetPageCount() <= 1: 141 style = self.GetWindowStyleFlag() 142 flag = wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB 143 if style & wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB == flag: 144 style = style & ~wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB 145 self.SetWindowStyle(style) 146 else: 147 style = self.GetWindowStyleFlag() 148 flag = wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB 149 if style & wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB != flag: 150 style |= wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB 151 self.SetWindowStyle(style) 152 153 def on_close_page(self, event): 154 """ 155 close the page 156 """ 157 if self.GetPageCount() == 1: 158 event.Veto() 159 self.enable_close_button() 160 161 162 109 163 def set_data(self, data): 110 164 if data is None: … … 113 167 grid = GridPage(self, panel=self.parent) 114 168 grid.set_data(data) 115 self.AddPage(grid, "Batch") 116 117 169 self.AddPage(grid, "") 170 pos = self.GetPageIndex(grid) 171 title = "Batch " + str(self.GetPageCount()) 172 self.SetPageText(pos, title) 173 174 def add_column(self): 175 """ 176 Append a new column to the grid 177 """ 178 pos = self.GetSelection() 179 grid = self.GetPage(pos) 180 grid.AppendCols(1, True) 181 182 def on_remove_column(self): 183 """ 184 Remove column to the current grid 185 """ 186 pos = self.GetSelection() 187 grid = self.GetPage(pos) 188 cols_pos = grid.GetSelectedCols() 189 for cpos in cols_pos: 190 grid.DeleteCols(cpos) 191 192 118 193 class SPanel(ScrolledPanel): 119 194 def __init__(self, parent, *args, **kwds): 120 195 ScrolledPanel.__init__(self, parent , *args, **kwds) 121 196 self.SetupScrolling() 197 122 198 123 199 class GridPanel(SPanel): … … 236 312 237 313 def add_column(self): 314 """ 315 """ 238 316 if self.grid is not None: 239 317 self.grid.add_column() 318 319 def on_remove_column(self): 320 """ 321 """ 322 if self.grid is not None: 323 self.grid.on_remove_column() 240 324 241 325 … … 246 330 self.panel = GridPanel(self, data) 247 331 menubar = wx.MenuBar() 332 self.SetMenuBar(menubar) 248 333 edit = wx.Menu() 249 id_col = wx.NewId() 250 edit.Append(id_col, 'Edit', '' ) 251 menubar.Append(edit, "&New column") 252 self.SetMenuBar(menubar) 253 wx.EVT_MENU(self, id_col, self.on_add_column) 334 menubar.Append(edit, "&Edit") 254 335 self.Bind(wx.EVT_CLOSE, self.on_close) 255 256 336 337 add_col_menu = edit.Append(wx.NewId(), 'Add Column', 'Add column') 338 wx.EVT_MENU(self, add_col_menu.GetId(), self.on_add_column) 339 remove_col_menu = edit.Append(wx.NewId(), 'Remove Column', 340 'Remove Column') 341 wx.EVT_MENU(self, remove_col_menu.GetId(), self.on_remove_column) 342 257 343 def on_close(self, event): 258 344 """ … … 260 346 self.Hide() 261 347 348 def on_remove_column(self, event): 349 """ 350 Remove the selected column to the grid 351 """ 352 self.panel.on_remove_column() 353 262 354 def on_add_column(self, event): 263 355 """ 356 Append a new column to the grid 264 357 """ 265 358 self.panel.add_column() … … 281 374 data["index"+str(i)] = [i/j, i*j, i, i+j] 282 375 283 frame = TestFrame(data=data)376 frame = GridFrame(data=data) 284 377 frame.Show(True) 285 378 except:
Note: See TracChangeset
for help on using the changeset viewer.