Changeset 225aca8 in sasview for src/sas/guiframe/gui_manager.py
- Timestamp:
- Jul 28, 2015 10:14:38 AM (9 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:
- a910c788
- Parents:
- ae2a197 (diff), d06c34c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/guiframe/gui_manager.py
r957af0d r225aca8 235 235 Initialize the Frame object 236 236 """ 237 238 237 PARENT_FRAME.__init__(self, parent=parent, title=title, pos=pos, size=size) 239 238 # title … … 364 363 frame.SetIcon(icon) 365 364 except: 366 pass365 logging.error("ViewerFrame.put_icon: could not set icon") 367 366 368 367 def get_client_size(self): … … 752 751 self._toolbar.Realize() 753 752 754 755 753 def build_gui(self): 756 754 """ … … 778 776 # Append item from plugin under menu file if necessary 779 777 self._populate_file_menu() 780 781 778 782 779 if not wx.VERSION_STRING >= '3.0.0.0': … … 822 819 # Load panels 823 820 self._load_panels() 824 self.set_default_perspective()825 821 826 822 def SetStatusText(self, *args, **kwds): … … 931 927 if hasattr(module, "PLUGIN_ID"): 932 928 try: 933 plug = module.Plugin() 934 if plug.set_default_perspective(): 935 self._current_perspective = plug 936 plugins.append(plug) 937 929 plugins.append(module.Plugin()) 938 930 msg = "Found plug-in: %s" % module.PLUGIN_ID 939 931 logging.info(msg) … … 1511 1503 for item in plugin.populate_file_menu(): 1512 1504 m_name, m_hint, m_handler = item 1513 id = wx.NewId()1514 self._file_menu.Append( id, m_name, m_hint)1515 wx.EVT_MENU(self, id, m_handler)1505 wx_id = wx.NewId() 1506 self._file_menu.Append(wx_id, m_name, m_hint) 1507 wx.EVT_MENU(self, wx_id, m_handler) 1516 1508 self._file_menu.AppendSeparator() 1517 1509 1518 1510 style1 = self.__gui_style & GUIFRAME.MULTIPLE_APPLICATIONS 1519 1511 if OPEN_SAVE_MENU: 1520 id = wx.NewId()1512 wx_id = wx.NewId() 1521 1513 hint_load_file = "read all analysis states saved previously" 1522 self._save_appl_menu = self._file_menu.Append( id, '&Open Project', hint_load_file)1523 wx.EVT_MENU(self, id, self._on_open_state_project)1514 self._save_appl_menu = self._file_menu.Append(wx_id, '&Open Project', hint_load_file) 1515 wx.EVT_MENU(self, wx_id, self._on_open_state_project) 1524 1516 1525 1517 if style1 == GUIFRAME.MULTIPLE_APPLICATIONS: … … 1527 1519 hint_load_file = "Read a status files and load" 1528 1520 hint_load_file += " them into the analysis" 1529 id = wx.NewId()1530 self._save_appl_menu = self._file_menu.Append( id,1521 wx_id = wx.NewId() 1522 self._save_appl_menu = self._file_menu.Append(wx_id, 1531 1523 '&Open Analysis', hint_load_file) 1532 wx.EVT_MENU(self, id, self._on_open_state_application)1524 wx.EVT_MENU(self, wx_id, self._on_open_state_application) 1533 1525 if OPEN_SAVE_MENU: 1534 1526 self._file_menu.AppendSeparator() 1535 id = wx.NewId()1536 self._file_menu.Append( id, '&Save Project',1527 wx_id = wx.NewId() 1528 self._file_menu.Append(wx_id, '&Save Project', 1537 1529 'Save the state of the whole analysis') 1538 wx.EVT_MENU(self, id, self._on_save_project)1530 wx.EVT_MENU(self, wx_id, self._on_save_project) 1539 1531 if style1 == GUIFRAME.MULTIPLE_APPLICATIONS: 1540 id = wx.NewId()1541 self._save_appl_menu = self._file_menu.Append( id, \1532 wx_id = wx.NewId() 1533 self._save_appl_menu = self._file_menu.Append(wx_id, \ 1542 1534 '&Save Analysis', 'Save state of the current active analysis panel') 1543 wx.EVT_MENU(self, id, self._on_save_application)1535 wx.EVT_MENU(self, wx_id, self._on_save_application) 1544 1536 if not sys.platform == 'darwin': 1545 1537 self._file_menu.AppendSeparator() 1546 id = wx.NewId()1547 self._file_menu.Append( id, '&Quit', 'Exit')1548 wx.EVT_MENU(self, id, self.Close)1538 wx_id = wx.NewId() 1539 self._file_menu.Append(wx_id, '&Quit', 'Exit') 1540 wx.EVT_MENU(self, wx_id, self.Close) 1549 1541 1550 1542 def _add_menu_file(self): … … 1717 1709 """ 1718 1710 """ 1719 message = ""1720 1711 log_msg = '' 1721 output = []1722 error_message = ""1723 1712 basename = os.path.basename(path) 1724 root, extension = os.path.splitext(basename)1713 _, extension = os.path.splitext(basename) 1725 1714 if extension.lower() not in EXTENSIONS: 1726 1715 log_msg = "File Loader cannot " … … 2224 2213 if hasattr(item, "post_init"): 2225 2214 item.post_init() 2226 2227 def set_default_perspective(self):2228 """2229 Choose among the plugin the first plug-in that has2230 "set_default_perspective" method and its return value is True will be2231 as a default perspective when the welcome page is closed2232 """2233 for item in self.plugins:2234 if hasattr(item, "set_default_perspective"):2235 if item.set_default_perspective():2236 item.on_perspective(event=None)2237 return2238 2215 2239 2216 def set_perspective(self, panels): … … 2414 2391 total_plot_list.append(theory_data) 2415 2392 for new_plot in total_plot_list: 2416 id = new_plot.id2417 2393 for group_id in new_plot.list_group_id: 2418 wx.PostEvent(self, NewPlotEvent(id= id,2394 wx.PostEvent(self, NewPlotEvent(id=new_plot.id, 2419 2395 group_id=group_id, 2420 2396 action='remove')) 2421 2397 #remove res plot: Todo: improve 2422 wx.CallAfter(self._remove_res_plot, id)2398 wx.CallAfter(self._remove_res_plot, new_plot.id) 2423 2399 self._data_manager.delete_data(data_id=data_id, 2424 2400 theory_id=theory_id) … … 2455 2431 ext_num = dlg.GetFilterIndex() 2456 2432 if ext_num == 0: 2457 format = '.txt'2433 ext_format = '.txt' 2458 2434 else: 2459 format = '.xml'2460 path = os.path.splitext(path)[0] + format2435 ext_format = '.xml' 2436 path = os.path.splitext(path)[0] + ext_format 2461 2437 mypath = os.path.basename(path) 2462 2438 2463 2439 #Instantiate a loader 2464 2440 loader = Loader() 2465 format = ".txt"2466 if os.path.splitext(mypath)[1].lower() == format:2441 ext_format = ".txt" 2442 if os.path.splitext(mypath)[1].lower() == ext_format: 2467 2443 # Make sure the ext included in the file name 2468 2444 # especially on MAC 2469 fName = os.path.splitext(path)[0] + format2445 fName = os.path.splitext(path)[0] + ext_format 2470 2446 self._onsaveTXT(data, fName) 2471 format = ".xml"2472 if os.path.splitext(mypath)[1].lower() == format:2447 ext_format = ".xml" 2448 if os.path.splitext(mypath)[1].lower() == ext_format: 2473 2449 # Make sure the ext included in the file name 2474 2450 # especially on MAC 2475 fName = os.path.splitext(path)[0] + format2476 loader.save(fName, data, format)2451 fName = os.path.splitext(path)[0] + ext_format 2452 loader.save(fName, data, ext_format) 2477 2453 try: 2478 2454 self._default_save_location = os.path.dirname(path) … … 2598 2574 ext_num = dlg.GetFilterIndex() 2599 2575 if ext_num == 0: 2600 format = '.dat'2576 ext_format = '.dat' 2601 2577 else: 2602 format = ''2603 path = os.path.splitext(path)[0] + format2578 ext_format = '' 2579 path = os.path.splitext(path)[0] + ext_format 2604 2580 mypath = os.path.basename(path) 2605 2581 … … 2607 2583 loader = Loader() 2608 2584 2609 format = ".dat"2610 if os.path.splitext(mypath)[1].lower() == format:2585 ext_format = ".dat" 2586 if os.path.splitext(mypath)[1].lower() == ext_format: 2611 2587 # Make sure the ext included in the file name 2612 2588 # especially on MAC 2613 fileName = os.path.splitext(path)[0] + format2614 loader.save(fileName, data, format)2589 fileName = os.path.splitext(path)[0] + ext_format 2590 loader.save(fileName, data, ext_format) 2615 2591 try: 2616 2592 self._default_save_location = os.path.dirname(path) … … 3206 3182 3207 3183 3208 class ViewApp(wx.App):3184 class SasViewApp(wx.App): 3209 3185 """ 3210 Toy application to test this Frame3186 SasView application 3211 3187 """ 3212 3188 def OnInit(self): … … 3294 3270 if len(os.listdir(model_folder)) > 0: 3295 3271 try: 3296 for file in os.listdir(model_folder):3297 file_path = os.path.join(model_folder, file )3272 for filename in os.listdir(model_folder): 3273 file_path = os.path.join(model_folder, filename) 3298 3274 if os.path.isfile(file_path): 3299 3275 os.remove(file_path) … … 3314 3290 """ 3315 3291 #try to load file at the start 3316 try: 3317 self.open_file() 3318 except: 3319 raise 3292 self.open_file() 3320 3293 self.frame.build_gui() 3321 3294
Note: See TracChangeset
for help on using the changeset viewer.