[e2f1023] | 1 | |
---|
| 2 | import numpy |
---|
| 3 | import string |
---|
[d89f09b] | 4 | import wx |
---|
[26bf293] | 5 | import wx.aui |
---|
[330573d] | 6 | |
---|
[cfc0913] | 7 | import basepage |
---|
[00c3aac] | 8 | |
---|
[330573d] | 9 | _BOX_WIDTH = 80 |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | class StateIterator(object): |
---|
[1b69256] | 13 | """ |
---|
[5062bbf] | 14 | Contains all saved state of a given page. |
---|
| 15 | Provide position of the current state of a page, the first save state |
---|
| 16 | and the last state for a given page. |
---|
| 17 | Allow easy undo or redo for a given page |
---|
[1b69256] | 18 | """ |
---|
[330573d] | 19 | def __init__(self): |
---|
[5062bbf] | 20 | """ |
---|
| 21 | """ |
---|
[330573d] | 22 | self._current=0 |
---|
| 23 | |
---|
| 24 | def __iter__(self): |
---|
[5062bbf] | 25 | """ |
---|
| 26 | """ |
---|
[330573d] | 27 | return self |
---|
| 28 | |
---|
| 29 | def first(self): |
---|
[5062bbf] | 30 | """ |
---|
| 31 | """ |
---|
[330573d] | 32 | self._current =0 |
---|
| 33 | return self._current |
---|
| 34 | |
---|
| 35 | def next(self, max ): |
---|
[5062bbf] | 36 | """ |
---|
| 37 | """ |
---|
[330573d] | 38 | if self._current < max: |
---|
| 39 | self._current += 1 |
---|
| 40 | return self._current |
---|
| 41 | |
---|
| 42 | def previous(self): |
---|
[5062bbf] | 43 | """ |
---|
| 44 | """ |
---|
[330573d] | 45 | if self._current > 0: |
---|
| 46 | self._current = self._current -1 |
---|
| 47 | return self._current |
---|
| 48 | |
---|
| 49 | def currentPosition(self): |
---|
[5062bbf] | 50 | """ |
---|
| 51 | """ |
---|
[330573d] | 52 | return self._current |
---|
| 53 | |
---|
| 54 | def setPosition(self, value): |
---|
[5062bbf] | 55 | """ |
---|
| 56 | """ |
---|
[330573d] | 57 | if value >=0: |
---|
| 58 | self._current = int(value) |
---|
| 59 | |
---|
| 60 | |
---|
[5062bbf] | 61 | class ListOfState(list): |
---|
| 62 | """ |
---|
| 63 | """ |
---|
[330573d] | 64 | def __init__(self, *args, **kw): |
---|
| 65 | list.__init__(self, *args, **kw) |
---|
| 66 | self.iterator = StateIterator() |
---|
| 67 | |
---|
| 68 | def appendItem(self, x): |
---|
[5062bbf] | 69 | """ |
---|
| 70 | """ |
---|
[330573d] | 71 | self.append(x) |
---|
| 72 | self.iterator.setPosition(value= len(self)-1) |
---|
| 73 | |
---|
| 74 | def removeItem(self, x): |
---|
[5062bbf] | 75 | """ |
---|
| 76 | """ |
---|
[330573d] | 77 | self.iterator.previous() |
---|
| 78 | self.remove(x) |
---|
| 79 | |
---|
| 80 | def getPreviousItem(self): |
---|
[5062bbf] | 81 | """ |
---|
| 82 | """ |
---|
[330573d] | 83 | position = self.iterator.previous() |
---|
| 84 | |
---|
| 85 | if position < 0: |
---|
| 86 | return None |
---|
| 87 | else: |
---|
| 88 | return self[position] |
---|
| 89 | |
---|
| 90 | def getNextItem(self): |
---|
[5062bbf] | 91 | """ |
---|
| 92 | """ |
---|
[fe496eeb] | 93 | position = self.iterator.next(max= len(self)-1) |
---|
[330573d] | 94 | if position >= len(self): |
---|
| 95 | return None |
---|
| 96 | else: |
---|
| 97 | return self[position] |
---|
| 98 | |
---|
| 99 | def getCurrentItem(self): |
---|
[5062bbf] | 100 | """ |
---|
| 101 | """ |
---|
[330573d] | 102 | postion = self.iterator.currentPosition() |
---|
| 103 | if postion >= 0 and position < len(self): |
---|
| 104 | return self[postion] |
---|
| 105 | else: |
---|
| 106 | return None |
---|
| 107 | |
---|
| 108 | def getCurrentPosition(self): |
---|
[5062bbf] | 109 | """ |
---|
| 110 | """ |
---|
[330573d] | 111 | return self.iterator.currentPosition() |
---|
[2f189dc] | 112 | |
---|
[330573d] | 113 | |
---|
[cfc0913] | 114 | class PageInfo(object): |
---|
| 115 | """ |
---|
[5062bbf] | 116 | this class contains the minimum numbers of data members |
---|
| 117 | a fitpage or model page need to be initialized. |
---|
[cfc0913] | 118 | """ |
---|
| 119 | data = None |
---|
[ffa69b6] | 120 | model = None |
---|
| 121 | manager = None |
---|
[cfc0913] | 122 | event_owner= None |
---|
| 123 | model_list_box = None |
---|
[ffa69b6] | 124 | name = None |
---|
[330573d] | 125 | ## Internal name for the AUI manager |
---|
[cfc0913] | 126 | window_name = "Page" |
---|
| 127 | ## Title to appear on top of the window |
---|
| 128 | window_caption = "Page" |
---|
[2f189dc] | 129 | #type of page can be real data , theory 1D or therory2D |
---|
| 130 | type = "Data" |
---|
| 131 | def __init__(self, model=None, data=None, manager=None, |
---|
| 132 | event_owner=None, model_list_box=None, name=None): |
---|
[cfc0913] | 133 | """ |
---|
[5062bbf] | 134 | Initialize data members |
---|
[cfc0913] | 135 | """ |
---|
| 136 | self.data = data |
---|
| 137 | self.model= model |
---|
| 138 | self.manager= manager |
---|
| 139 | self.event_owner= event_owner |
---|
| 140 | self.model_list_box = model_list_box |
---|
| 141 | self.name=None |
---|
| 142 | self.window_name = "Page" |
---|
| 143 | self.window_caption = "Page" |
---|
[2f189dc] | 144 | self.type = "Data" |
---|
| 145 | |
---|
[90d04eb] | 146 | class FitPanel(wx.aui.AuiNotebook): |
---|
[925a30e] | 147 | |
---|
[d89f09b] | 148 | """ |
---|
[5062bbf] | 149 | FitPanel class contains fields allowing to fit models and data |
---|
| 150 | |
---|
| 151 | :note: For Fit to be performed the user should check at least one parameter |
---|
[d89f09b] | 152 | on fit Panel window. |
---|
| 153 | |
---|
| 154 | """ |
---|
| 155 | ## Internal name for the AUI manager |
---|
| 156 | window_name = "Fit panel" |
---|
| 157 | ## Title to appear on top of the window |
---|
| 158 | window_caption = "Fit Panel " |
---|
[2139c3f] | 159 | CENTER_PANE = True |
---|
[7437880] | 160 | |
---|
[d89f09b] | 161 | def __init__(self, parent, *args, **kwargs): |
---|
[5062bbf] | 162 | """ |
---|
| 163 | """ |
---|
[90d04eb] | 164 | wx.aui.AuiNotebook.__init__(self, parent, -1, |
---|
[3244cbe1] | 165 | style= wx.aui.AUI_NB_WINDOWLIST_BUTTON| |
---|
| 166 | wx.aui.AUI_NB_DEFAULT_STYLE| |
---|
| 167 | wx.CLIP_CHILDREN) |
---|
[848a2ef] | 168 | |
---|
[d89f09b] | 169 | self.manager=None |
---|
| 170 | self.parent=parent |
---|
| 171 | self.event_owner=None |
---|
[26bf293] | 172 | |
---|
[3244cbe1] | 173 | pageClosedEvent = wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE |
---|
[2f189dc] | 174 | self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.on_close_page) |
---|
[51d47b5] | 175 | |
---|
[d89f09b] | 176 | #dictionary of miodel {model class name, model class} |
---|
[2f189dc] | 177 | self.model_list_box = {} |
---|
[cfc0913] | 178 | ## save the title of the last page tab added |
---|
[2f189dc] | 179 | self.fit_page_name = {} |
---|
[cfc0913] | 180 | ## list of existing fit page |
---|
[2f189dc] | 181 | self.opened_pages = {} |
---|
| 182 | #page of simultaneous fit |
---|
[ffa69b6] | 183 | self.sim_page = None |
---|
[cfc0913] | 184 | ## get the state of a page |
---|
| 185 | self.Bind(basepage.EVT_PAGE_INFO, self._onGetstate) |
---|
[330573d] | 186 | self.Bind(basepage.EVT_PREVIOUS_STATE, self._onUndo) |
---|
[fe496eeb] | 187 | self.Bind(basepage.EVT_NEXT_STATE, self._onRedo) |
---|
[9237df4] | 188 | |
---|
| 189 | #add default page |
---|
| 190 | from hint_fitpage import HintFitPage |
---|
[2377cd4] | 191 | self.hint_page = HintFitPage(self) |
---|
| 192 | self.AddPage(page=self.hint_page, caption="Hint") |
---|
[ffa69b6] | 193 | #Add the first fit page |
---|
[2f189dc] | 194 | self.add_empty_page() |
---|
[ffa69b6] | 195 | |
---|
[6bcdad1] | 196 | # increment number for model name |
---|
| 197 | self.count=0 |
---|
[f39511b] | 198 | #updating the panel |
---|
[26bf293] | 199 | self.Update() |
---|
[d89f09b] | 200 | self.Center() |
---|
[31b0c47] | 201 | |
---|
| 202 | def set_state(self, state): |
---|
| 203 | """ |
---|
[5062bbf] | 204 | Restore state of the panel |
---|
[31b0c47] | 205 | """ |
---|
| 206 | page_is_opened = False |
---|
| 207 | if state is not None: |
---|
| 208 | page_info = self.get_page_info(data=state.data) |
---|
| 209 | for name, panel in self.opened_pages.values(): |
---|
| 210 | #Don't return any panel is the exact same page is created |
---|
| 211 | if name == page_info.window_name: |
---|
| 212 | # the page is still opened |
---|
| 213 | panel.reset_page(state=state) |
---|
| 214 | page_is_opened = True |
---|
| 215 | if not page_is_opened: |
---|
| 216 | panel = self.add_fit_page(data=state.data) |
---|
| 217 | # add data associated to the page created |
---|
| 218 | if panel is not None: |
---|
| 219 | self.manager.store_page(page=panel, data=state.data) |
---|
| 220 | panel.reset_page(state=state) |
---|
| 221 | |
---|
[2f189dc] | 222 | def on_close_page(self, event): |
---|
[51d47b5] | 223 | """ |
---|
[5062bbf] | 224 | close page and remove all references to the closed page |
---|
[51d47b5] | 225 | """ |
---|
[d361b462] | 226 | nbr_page = self.GetPageCount() |
---|
| 227 | if nbr_page == 1: |
---|
| 228 | event.Veto() |
---|
| 229 | return |
---|
[51d47b5] | 230 | selected_page = self.GetPage(self.GetSelection()) |
---|
[2f189dc] | 231 | self._close_helper(selected_page=selected_page) |
---|
[9853ad0] | 232 | |
---|
[2f189dc] | 233 | def close_page_with_data(self, deleted_data): |
---|
| 234 | """ |
---|
[5062bbf] | 235 | close a fit page when its data is completely remove from the graph |
---|
[2f189dc] | 236 | """ |
---|
[784e2fa] | 237 | if deleted_data is None: |
---|
| 238 | return |
---|
[2f189dc] | 239 | for index in range(self.GetPageCount()): |
---|
| 240 | selected_page = self.GetPage(index) |
---|
| 241 | if hasattr(selected_page,"get_data"): |
---|
| 242 | data = selected_page.get_data() |
---|
[784e2fa] | 243 | if data is None: |
---|
| 244 | #the fitpanel exists and only the initial fit page is open |
---|
| 245 | #with no selected data |
---|
| 246 | return |
---|
[2f189dc] | 247 | if data.name == deleted_data.name: |
---|
| 248 | self._close_helper(selected_page) |
---|
| 249 | self.DeletePage(index) |
---|
| 250 | break |
---|
[d89f09b] | 251 | |
---|
| 252 | def set_manager(self, manager): |
---|
| 253 | """ |
---|
[5062bbf] | 254 | set panel manager |
---|
| 255 | |
---|
| 256 | :param manager: instance of plugin fitting |
---|
| 257 | |
---|
[d89f09b] | 258 | """ |
---|
| 259 | self.manager = manager |
---|
[925a30e] | 260 | |
---|
[d89f09b] | 261 | |
---|
| 262 | def set_owner(self,owner): |
---|
| 263 | """ |
---|
[5062bbf] | 264 | set and owner for fitpanel |
---|
| 265 | |
---|
| 266 | :param owner: the class responsible of plotting |
---|
| 267 | |
---|
[d89f09b] | 268 | """ |
---|
[c77d859] | 269 | self.event_owner = owner |
---|
| 270 | |
---|
[ffa69b6] | 271 | def set_model_list(self, dict): |
---|
[c77d859] | 272 | """ |
---|
[5062bbf] | 273 | copy a dictionary of model into its own dictionary |
---|
| 274 | |
---|
| 275 | :param dict: dictionnary made of model name as key and model class |
---|
[c77d859] | 276 | as value |
---|
| 277 | """ |
---|
| 278 | self.model_list_box = dict |
---|
[51d47b5] | 279 | |
---|
[c77d859] | 280 | def get_current_page(self): |
---|
| 281 | """ |
---|
[5062bbf] | 282 | :return: the current page selected |
---|
| 283 | |
---|
[c77d859] | 284 | """ |
---|
| 285 | return self.GetPage(self.GetSelection() ) |
---|
| 286 | |
---|
[51d47b5] | 287 | def add_sim_page(self): |
---|
[925a30e] | 288 | """ |
---|
[5062bbf] | 289 | Add the simultaneous fit page |
---|
[925a30e] | 290 | """ |
---|
[51d47b5] | 291 | from simfitpage import SimultaneousFitPage |
---|
[b28717b] | 292 | page_finder= self.manager.get_page_finder() |
---|
| 293 | self.sim_page = SimultaneousFitPage(self,page_finder=page_finder, id=-1) |
---|
| 294 | |
---|
[51d47b5] | 295 | self.AddPage(self.sim_page,caption="Simultaneous Fit",select=True) |
---|
| 296 | self.sim_page.set_manager(self.manager) |
---|
| 297 | return self.sim_page |
---|
[d89f09b] | 298 | |
---|
[2f189dc] | 299 | def get_page_info(self, data=None): |
---|
| 300 | """ |
---|
[5062bbf] | 301 | fill information required to add a page in the fit panel |
---|
[2f189dc] | 302 | """ |
---|
| 303 | name = "Fit Page" |
---|
| 304 | type = 'empty' |
---|
[ffa69b6] | 305 | if data is not None: |
---|
| 306 | if data.is_data: |
---|
| 307 | name = data.name |
---|
[2f189dc] | 308 | type = 'Data' |
---|
[882a912] | 309 | else: |
---|
[2f189dc] | 310 | if data.__class__.__name__ == "Data2D": |
---|
[ffa69b6] | 311 | name = 'Model 2D Fit' |
---|
[2f189dc] | 312 | type = 'Theory2D' |
---|
[ffa69b6] | 313 | else: |
---|
| 314 | name = 'Model 1D Fit' |
---|
[2f189dc] | 315 | type = 'Theory1D' |
---|
| 316 | page_info = PageInfo(data=data, name=name) |
---|
| 317 | page_info.event_owner = self.event_owner |
---|
| 318 | page_info.manager = self.manager |
---|
| 319 | page_info.window_name = name |
---|
| 320 | page_info.window_caption = name |
---|
| 321 | page_info.type = type |
---|
| 322 | return page_info |
---|
[9853ad0] | 323 | |
---|
[2f189dc] | 324 | def add_empty_page(self): |
---|
[9853ad0] | 325 | """ |
---|
[5062bbf] | 326 | add an empty page |
---|
[9853ad0] | 327 | """ |
---|
[2f189dc] | 328 | page_info = self.get_page_info() |
---|
| 329 | from fitpage import FitPage |
---|
| 330 | panel = FitPage(parent=self, page_info=page_info) |
---|
| 331 | self.AddPage(page=panel, caption=page_info.window_name, select=True) |
---|
| 332 | self.opened_pages[page_info.type] = [page_info.window_name, panel] |
---|
| 333 | return panel |
---|
| 334 | |
---|
| 335 | def add_page(self, page_info): |
---|
[848a2ef] | 336 | """ |
---|
[5062bbf] | 337 | add a new page |
---|
[848a2ef] | 338 | """ |
---|
[2f189dc] | 339 | from fitpage import FitPage |
---|
| 340 | panel = FitPage(parent=self, page_info=page_info) |
---|
| 341 | self.AddPage(page=panel, caption=page_info.window_name, select=True) |
---|
| 342 | index = self.GetPageIndex(panel) |
---|
| 343 | self.change_page_content(data=page_info.data, index=index) |
---|
| 344 | return panel |
---|
[848a2ef] | 345 | |
---|
[2f189dc] | 346 | def change_page_content(self, data, index): |
---|
| 347 | """ |
---|
[5062bbf] | 348 | replace the contains of an existing page |
---|
[2f189dc] | 349 | """ |
---|
| 350 | page_info = self.get_page_info(data=data) |
---|
| 351 | self.SetPageText(index, page_info.window_name) |
---|
| 352 | panel = self.GetPage(index) |
---|
| 353 | panel.set_data(data) |
---|
| 354 | if panel.model_list_box is None or len(panel.model_list_box) == 0: |
---|
| 355 | page_info.model_list_box = self.model_list_box.get_list() |
---|
| 356 | panel.populate_box(dict=page_info.model_list_box) |
---|
| 357 | panel.initialize_combox() |
---|
| 358 | panel.set_page_info(page_info=page_info) |
---|
| 359 | self.opened_pages[page_info.type] = [page_info.window_name, panel] |
---|
| 360 | return panel |
---|
| 361 | |
---|
| 362 | def replace_page(self, index, page_info, type): |
---|
| 363 | """ |
---|
[5062bbf] | 364 | replace an existing page |
---|
[2f189dc] | 365 | """ |
---|
| 366 | self.DeletePage(index) |
---|
| 367 | del self.opened_pages[type] |
---|
| 368 | return self.add_page(page_info=page_info) |
---|
[848a2ef] | 369 | |
---|
[2f189dc] | 370 | def add_fit_page(self, data, reset=False): |
---|
| 371 | """ |
---|
[5062bbf] | 372 | Add a fitting page on the notebook contained by fitpanel |
---|
| 373 | |
---|
| 374 | :param data: data to fit |
---|
| 375 | |
---|
| 376 | :return panel : page just added for further used. is used by fitting module |
---|
| 377 | |
---|
[2f189dc] | 378 | """ |
---|
| 379 | if data is None: |
---|
| 380 | return None |
---|
| 381 | page_info = self.get_page_info(data=data) |
---|
| 382 | type = page_info.type |
---|
| 383 | npages = len(self.opened_pages.keys()) |
---|
| 384 | #check if only and empty page is opened |
---|
| 385 | if len(self.opened_pages.keys()) > 0: |
---|
| 386 | first_page_type = self.opened_pages.keys()[0] |
---|
| 387 | if npages == 1 and first_page_type in ['empty']: |
---|
| 388 | #replace the first empty page |
---|
| 389 | name, panel = self.opened_pages[first_page_type] |
---|
| 390 | index = self.GetPageIndex(panel) |
---|
| 391 | panel = self.change_page_content(data=data, index=index) |
---|
| 392 | del self.opened_pages[first_page_type] |
---|
| 393 | return panel |
---|
| 394 | if type in self.opened_pages.keys(): |
---|
| 395 | #this type of page is already created but it is a theory |
---|
| 396 | # meaning the same page is just to fit different data |
---|
| 397 | if not type.lower() in ['data']: |
---|
| 398 | #delete the previous theory page and add a new one |
---|
| 399 | name, panel = self.opened_pages[type] |
---|
[286bb6c] | 400 | #self.manager.reset_plot_panel(panel.get_data()) |
---|
[2f189dc] | 401 | #delete the existing page and replace it |
---|
| 402 | index = self.GetPageIndex(panel) |
---|
| 403 | panel = self.replace_page(index=index, page_info=page_info, type=type) |
---|
| 404 | return panel |
---|
| 405 | else: |
---|
| 406 | for name, panel in self.opened_pages.values(): |
---|
| 407 | #Don't return any panel is the exact same page is created |
---|
| 408 | if name == page_info.window_name: |
---|
| 409 | return None |
---|
| 410 | else: |
---|
| 411 | panel = self.add_page(page_info=page_info) |
---|
| 412 | return panel |
---|
| 413 | else: |
---|
| 414 | #a new type of page is created |
---|
| 415 | panel = self.add_page(page_info=page_info) |
---|
| 416 | return panel |
---|
| 417 | |
---|
[cfc0913] | 418 | def _onGetstate(self, event): |
---|
| 419 | """ |
---|
[5062bbf] | 420 | copy the state of a page |
---|
[cfc0913] | 421 | """ |
---|
| 422 | page= event.page |
---|
[b787e68c] | 423 | if page.window_name in self.fit_page_name: |
---|
[330573d] | 424 | self.fit_page_name[page.window_name].appendItem(page.createMemento()) |
---|
[cfc0913] | 425 | |
---|
[330573d] | 426 | def _onUndo(self, event ): |
---|
| 427 | """ |
---|
[5062bbf] | 428 | return the previous state of a given page is available |
---|
[330573d] | 429 | """ |
---|
| 430 | page = event.page |
---|
| 431 | if page.window_name in self.fit_page_name: |
---|
| 432 | if self.fit_page_name[page.window_name].getCurrentPosition()==0: |
---|
| 433 | state = None |
---|
| 434 | else: |
---|
| 435 | state = self.fit_page_name[page.window_name].getPreviousItem() |
---|
[fe496eeb] | 436 | page._redo.Enable(True) |
---|
[330573d] | 437 | page.reset_page(state) |
---|
[fe496eeb] | 438 | |
---|
[2f189dc] | 439 | def _onRedo(self, event): |
---|
[fe496eeb] | 440 | """ |
---|
[5062bbf] | 441 | return the next state available |
---|
[fe496eeb] | 442 | """ |
---|
| 443 | page = event.page |
---|
| 444 | if page.window_name in self.fit_page_name: |
---|
| 445 | length= len(self.fit_page_name[page.window_name]) |
---|
| 446 | if self.fit_page_name[page.window_name].getCurrentPosition()== length -1: |
---|
| 447 | state = None |
---|
| 448 | page._redo.Enable(False) |
---|
[3b9e023] | 449 | page._redo.Enable(True) |
---|
[fe496eeb] | 450 | else: |
---|
| 451 | state = self.fit_page_name[page.window_name].getNextItem() |
---|
| 452 | page.reset_page(state) |
---|
[2f189dc] | 453 | |
---|
| 454 | def _close_helper(self, selected_page): |
---|
[3f1af74] | 455 | """ |
---|
[5062bbf] | 456 | Delete the given page from the notebook |
---|
[3f1af74] | 457 | """ |
---|
[2f189dc] | 458 | #remove hint page |
---|
| 459 | if selected_page == self.hint_page: |
---|
| 460 | return |
---|
| 461 | ## removing sim_page |
---|
| 462 | if selected_page == self.sim_page : |
---|
| 463 | self.manager.sim_page=None |
---|
| 464 | return |
---|
[b787e68c] | 465 | |
---|
[2f189dc] | 466 | ## closing other pages |
---|
| 467 | state = selected_page.createMemento() |
---|
| 468 | page_name = selected_page.window_name |
---|
| 469 | page_finder = self.manager.get_page_finder() |
---|
| 470 | fitproblem = None |
---|
| 471 | ## removing fit page |
---|
[c6036f5] | 472 | data = selected_page.get_data() |
---|
| 473 | #Don' t remove plot for 2D |
---|
| 474 | flag = True |
---|
| 475 | if data.__class__.__name__ == 'Data2D': |
---|
| 476 | flag = False |
---|
[2f189dc] | 477 | if selected_page in page_finder: |
---|
| 478 | #Delete the name of the page into the list of open page |
---|
| 479 | for type, list in self.opened_pages.iteritems(): |
---|
| 480 | #Don't return any panel is the exact same page is created |
---|
| 481 | name = str(list[0]) |
---|
[c6036f5] | 482 | if flag and selected_page.window_name == name: |
---|
[2f189dc] | 483 | if type.lower() in ['theory1d', 'theory2d']: |
---|
| 484 | self.manager.remove_plot(selected_page, theory=True) |
---|
| 485 | else: |
---|
| 486 | self.manager.remove_plot(selected_page, theory=False) |
---|
| 487 | break |
---|
| 488 | del page_finder[selected_page] |
---|
| 489 | ##remove the check box link to the model name of this page (selected_page) |
---|
| 490 | try: |
---|
| 491 | self.sim_page.draw_page() |
---|
| 492 | except: |
---|
| 493 | ## that page is already deleted no need to remove check box on |
---|
| 494 | ##non existing page |
---|
| 495 | pass |
---|
| 496 | |
---|
| 497 | #Delete the name of the page into the list of open page |
---|
| 498 | for type, list in self.opened_pages.iteritems(): |
---|
| 499 | #Don't return any panel is the exact same page is created |
---|
| 500 | name = str(list[0]) |
---|
| 501 | if selected_page.window_name == name: |
---|
| 502 | del self.opened_pages[type] |
---|
| 503 | break |
---|
[0aeabc6] | 504 | |
---|
[b787e68c] | 505 | |
---|