Changeset b25caad in sasview for fittingview/src/sans
- Timestamp:
- Jan 14, 2012 4:13:47 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:
- f706e09c
- Parents:
- 6f140f2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fittingview/src/sans/perspectives/fitting/fitting.py
r6f140f2 rb25caad 249 249 frame.Show(True) 250 250 251 def delete_custom_model(self, event): 252 """ 253 Delete custom model file 254 """ 255 id = event.GetId() 256 label = self.delete_menu.GetLabel(id) 257 toks = os.path.splitext(label) 258 path = os.path.join(models.find_plugins_dir(), toks[0]) 259 try: 260 for ext in ['.py', '.pyc']: 261 p_path = path + ext 262 os.remove(p_path) 263 self.update_custom_combo() 264 self.delete_menu.Delete(id) 265 for item in self.edit_menu.GetMenuItems(): 266 if item.GetLabel() == label: 267 self.edit_menu.DeleteItem(item) 268 break 269 except: 270 msg ='Delete Error: \nCould not delete the file; Check if in use.' 271 wx.MessageBox(msg) 272 251 273 def make_sum_model(self, event): 252 274 """ … … 258 280 model_list = model_manager.get_model_name_list() 259 281 260 textdial = TextDialog(None, -1, ' Modify Sum(p1, p2) Model', model_list)282 textdial = TextDialog(None, -1, 'Easy Sum(p1, p2)', model_list) 261 283 self.put_icon(textdial) 262 284 if textdial.ShowModal() == wx.ID_OK: … … 264 286 label = textdial.getText() 265 287 plug_dir = models.find_plugins_dir() 266 fname = os.path.join(plug_dir, " sum_temp.py")288 fname = os.path.join(plug_dir, "easy_sum_of_p1_p2.py") 267 289 name1 = label[0] 268 290 name2 = label[1] … … 300 322 """ 301 323 try: 324 # Update edit menus 325 self.set_edit_menu_helper(self.parent, self.edit_custom_model) 326 self.set_edit_menu_helper(self.parent, self.delete_custom_model) 302 327 temp = self.fit_panel.reset_pmodel_list() 303 328 if temp: … … 309 334 pos = page.formfactorbox.GetSelection() 310 335 page._show_combox_helper() 311 page.formfactorbox.SetSelection(pos) 312 page.formfactorbox.SetValue(current_val) 336 new_val = page.formfactorbox.GetValue() 337 if current_val != new_val and new_val != '': 338 page.formfactorbox.SetValue(new_val) 339 else: 340 page.formfactorbox.SetValue(current_val) 313 341 except: 314 342 pass … … 321 349 id = wx.NewId() 322 350 #new_model_menu = wx.Menu() 323 self.edit_model_menu.Append(id, 'New Model Function',351 self.edit_model_menu.Append(id, 'New', 324 352 'Add a new model function')#, 325 353 #new_model_menu) 326 354 wx.EVT_MENU(owner, id, self.make_new_model) 327 355 id = wx.NewId() 328 self.edit_model_menu.Append(id, ' ModifySum(p1, p2)',356 self.edit_model_menu.Append(id, 'Sum(p1, p2)', 329 357 'Sum of two model functions') 330 358 wx.EVT_MENU(owner, id, self.make_sum_model) … … 332 360 self.edit_menu =wx.Menu() 333 361 self.edit_model_menu.AppendMenu(e_id, 334 'Advanced Edit', self.edit_menu) 335 self.set_edit_menu_helper(owner) 336 337 def set_edit_menu_helper(self, owner): 362 'Advanced', self.edit_menu) 363 self.set_edit_menu_helper(owner, self.edit_custom_model) 364 365 d_id = wx.NewId() 366 self.delete_menu =wx.Menu() 367 self.edit_model_menu.AppendMenu(d_id, 368 'Delete', self.delete_menu) 369 self.set_edit_menu_helper(owner, self.delete_custom_model) 370 371 def set_edit_menu_helper(self, owner, menu): 338 372 """ 339 373 help for setting list of the edit model menu labels … … 343 377 name = os.path.basename(item) 344 378 toks = os.path.splitext(name) 345 if toks[1]=='.py' and not toks[0] =='__init__' \ 346 and not toks[0] =='sum_temp': 379 if toks[-1]=='.py' and not toks[0] =='__init__': 380 if menu == self.edit_custom_model: 381 if toks[0] =='easy_sum_of_p1_p2': 382 continue 383 submenu = self.edit_menu 384 else: 385 submenu = self.delete_menu 386 #name = toks[0] 347 387 has_file = False 348 for item in s elf.edit_menu.GetMenuItems():349 if name == s elf.edit_menu.GetLabel(item.GetId()):388 for item in submenu.GetMenuItems(): 389 if name == submenu.GetLabel(item.GetId()): 350 390 has_file = True 351 391 if not has_file: 352 392 id = wx.NewId() 353 s elf.edit_menu.Append(id, name)354 wx.EVT_MENU(owner, id, self.edit_custom_model)393 submenu.Append(id, name) 394 wx.EVT_MENU(owner, id, menu) 355 395 has_file = False 356 396
Note: See TracChangeset
for help on using the changeset viewer.