Changeset f22e626 in sasview for sansview/perspectives/fitting/fitpanel.py
- Timestamp:
- May 13, 2011 2:53:43 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:
- 13a63ab
- Parents:
- 248b918
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/fitpanel.py
r4bee68d rf22e626 3 3 import string 4 4 import wx 5 import sys 5 6 #from wx.lib.flatnotebook import FlatNotebook as nb 6 7 from wx.aui import AuiNotebook as nb … … 46 47 self.model_list_box = self.menu_mng.get_model_list() 47 48 #pageClosedEvent = nb.EVT_FLATNOTEBOOK_PAGE_CLOSING 48 pageClosedEvent = wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE49 50 self.Bind( pageClosedEvent, self.on_close_page)49 self.pageClosedEvent = wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE 50 51 self.Bind(self.pageClosedEvent, self.on_close_page) 51 52 ## save the title of the last page tab added 52 53 self.fit_page_name = {} … … 61 62 self.Bind(basepage.EVT_NEXT_STATE, self._onRedo) 62 63 self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED, self.on_page_changing) 63 64 #add default pages 65 self.add_default_pages() 66 64 self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSED, self.on_closed) 65 66 def on_closed(self, event): 67 """ 68 """ 69 print "page closed", self.GetPageCount() 70 67 71 def save_project(self, doc=None): 68 72 """ … … 116 120 def on_page_changing(self, event): 117 121 """ 122 calls the function when the current event handler has exited. avoiding 123 to call panel on focus on a panel that is currently deleted 124 """ 125 wx.CallAfter(self.helper_on_page_change) 126 127 128 def helper_on_page_change(self): 129 """ 118 130 """ 119 131 pos = self.GetSelection() … … 121 133 selected_page = self.GetPage(pos) 122 134 wx.PostEvent(self.parent, PanelOnFocusEvent(panel=selected_page)) 123 135 136 124 137 def on_set_focus(self, event): 125 138 """ … … 157 170 return selected_page.get_state() 158 171 159 def add_default_pages(self): 160 """ 161 Add default pages such as a hint page and an empty fit page 162 """ 163 pass 164 #add default page 165 #from hint_fitpage import HintFitPage 166 #self.hint_page = HintFitPage(self) 167 #self.AddPage(self.hint_page,"Hint") 168 #self.hint_page.set_manager(self._manager) 172 169 173 170 174 def close_all(self): … … 228 232 """ 229 233 nbr_page = self.GetPageCount() 234 selected_page = self.GetPage(self.GetSelection()) 230 235 if nbr_page == 1: 231 232 event.Veto()233 return234 selected_page = self.GetPage(self.GetSelection())236 if selected_page.get_data() == None: 237 if event is not None: 238 event.Veto() 239 return 235 240 self._close_helper(selected_page=selected_page) 236 241 … … 250 255 #with no selected data 251 256 return 252 if data. name == deleted_data.name:257 if data.id == deleted_data.id: 253 258 self._close_helper(selected_page) 254 259 self.DeletePage(index) … … 294 299 self.AddPage(self.sim_page,"Simultaneous Fit", True) 295 300 self.sim_page.set_manager(self._manager) 301 self.enable_close_button() 296 302 return self.sim_page 297 303 … … 310 316 self.opened_pages[panel.uid] = panel 311 317 self.set_engine_helper(panel=panel) 318 self.enable_close_button() 312 319 return panel 313 320 321 def enable_close_button(self): 322 """ 323 display the close button on tab for more than 1 tabs else remove the 324 close button 325 """ 326 return 327 if self.GetPageCount() <= 1: 328 style = self.GetWindowStyleFlag() 329 if style & wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB == wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB: 330 style = style & ~wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB 331 self.SetWindowStyle(style) 332 else: 333 style = self.GetWindowStyleFlag() 334 if style & wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB != wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB: 335 style |= wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB 336 self.SetWindowStyle(style) 337 314 338 def delete_data(self, data): 315 339 """ 316 340 Delete the given data 317 341 """ 318 if data is None: 319 return None 342 if data.__class__.__name__ != "list": 343 raise ValueError, "Fitpanel delete_data expect list of id" 344 else: 345 n = self.GetPageCount() 346 for page in self.opened_pages.values(): 347 pos = self.GetPageIndex(page) 348 temp_data = page.get_data() 349 #stop the fitting before deleting the page 350 page.is_fitting() 351 if temp_data is not None and temp_data.id in data: 352 self.SetSelection(pos) 353 self.on_close_page(event=None) 354 temp = self.GetSelection() 355 self.DeletePage(temp) 356 if self.GetPageCount()== 0: 357 self.add_empty_page() 358 320 359 def set_data(self, data): 321 360 """ … … 435 474 for uid, list in self.opened_pages.iteritems(): 436 475 #Don't return any panel is the exact same page is created 437 438 476 if selected_page.uid == uid: 439 477 del self.opened_pages[selected_page.uid] 440 478 break 441 479 442 480
Note: See TracChangeset
for help on using the changeset viewer.