Changes in src/sas/sasgui/guiframe/gui_manager.py [8ac05a5:b1ec23d] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/gui_manager.py
r8ac05a5 rb1ec23d 46 46 from sas.sasgui.guiframe.CategoryManager import CategoryManager 47 47 from sas.sascalc.dataloader.loader import Loader 48 from sas.sascalc.file_converter.nxcansas_writer import NXcanSASWriter 48 49 from sas.sasgui.guiframe.proxy import Connection 49 50 … … 1276 1277 1277 1278 wx_id = wx.NewId() 1278 self._help_menu.Append(wx_id, '&Documentation', ' Help documentation for SasView')1279 self._help_menu.Append(wx_id, '&Documentation', '') 1279 1280 wx.EVT_MENU(self, wx_id, self._onSphinxDocs) 1280 1281 1281 1282 if config._do_tutorial and (IS_WIN or sys.platform == 'darwin'): 1282 1283 wx_id = wx.NewId() 1283 # Pluralised both occurences of 'Tutorial' in the line below 1284 # S King, Sep 2018 1285 self._help_menu.Append(wx_id, '&Tutorials', 'Tutorials on how to use SasView') 1284 self._help_menu.Append(wx_id, '&Tutorial', 'Software tutorial') 1286 1285 wx.EVT_MENU(self, wx_id, self._onTutorial) 1287 1288 if config.marketplace_url:1289 wx_id = wx.NewId()1290 self._help_menu.Append(wx_id, '&Model marketplace', 'Plug-in fitting models for SasView')1291 wx.EVT_MENU(self, wx_id, self._on_marketplace_click)1292 1293 if config._do_release:1294 wx_id = wx.NewId()1295 self._help_menu.Append(wx_id, '&Release notes',1296 'SasView release notes and known issues')1297 wx.EVT_MENU(self, wx_id, self._onRelease)1298 1286 1299 1287 if config._do_acknowledge: … … 1306 1294 logger.info("Doing help menu") 1307 1295 wx_id = wx.NewId() 1308 self._help_menu.Append(wx_id, '&About', ' Information about SasView')1296 self._help_menu.Append(wx_id, '&About', 'Software information') 1309 1297 wx.EVT_MENU(self, wx_id, self._onAbout) 1298 1299 if config.marketplace_url: 1300 wx_id = wx.NewId() 1301 self._help_menu.Append(wx_id, '&Model marketplace', '') 1302 wx.EVT_MENU(self, wx_id, self._on_marketplace_click) 1310 1303 1311 1304 # Checking for updates … … 2145 2138 dialog.ShowModal() 2146 2139 2147 def _on Release(self, evt):2148 """ 2149 Pop up the release notes2140 def _onTutorial(self, evt): 2141 """ 2142 Pop up the tutorial dialog 2150 2143 2151 2144 :param evt: menu event 2152 2145 2153 2146 """ 2154 # S King, Sep 2018 2155 2156 from documentation_window import DocumentationWindow 2157 _TreeLocation = "user/release.html" 2158 DocumentationWindow(self, -1, _TreeLocation, "", 2159 "SasView Documentation") 2160 2161 def _onTutorial(self, evt): 2162 """ 2163 Pop up the tutorial dialog 2164 2165 :param evt: menu event 2166 2167 """ 2168 # Action changed from that in 2.x/3.x/4.0.x/4.1.x 2169 # Help >> Tutorial used to bring up a pdf of the 2170 # original 2.x tutorial. 2171 # Code below, implemented from 4.2.0, redirects 2172 # action to the Tutorials page of the help 2173 # documentation to give access to all available 2174 # tutorials 2175 # S King, Sep 2018 2176 2177 from documentation_window import DocumentationWindow 2178 _TreeLocation = "user/tutorial.html" 2179 DocumentationWindow(self, -1, _TreeLocation, "", 2180 "SasView Documentation") 2147 if config._do_tutorial: 2148 path = config.TUTORIAL_PATH 2149 if IS_WIN: 2150 try: 2151 from sas.sasgui.guiframe.pdfview import PDFFrame 2152 dialog = PDFFrame(None, -1, "Tutorial", path) 2153 # put icon 2154 self.put_icon(dialog) 2155 dialog.Show(True) 2156 except: 2157 logger.error("Error in _onTutorial: %s" % sys.exc_value) 2158 try: 2159 # Try an alternate method 2160 logger.error( 2161 "Could not open the tutorial pdf, trying xhtml2pdf") 2162 from xhtml2pdf import pisa 2163 pisa.startViewer(path) 2164 except: 2165 logger.error( 2166 "Could not open the tutorial pdf with xhtml2pdf") 2167 msg = "This feature requires 'PDF Viewer'\n" 2168 wx.MessageBox(msg, 'Error') 2169 else: 2170 try: 2171 command = "open '%s'" % path 2172 os.system(command) 2173 except: 2174 try: 2175 # Try an alternate method 2176 logger.error( 2177 "Could not open the tutorial pdf, trying xhtml2pdf") 2178 from xhtml2pdf import pisa 2179 pisa.startViewer(path) 2180 except: 2181 logger.error( 2182 "Could not open the tutorial pdf with xhtml2pdf") 2183 msg = "This feature requires the Preview application\n" 2184 wx.MessageBox(msg, 'Error') 2181 2185 2182 2186 def _onSphinxDocs(self, evt): … … 2419 2423 default_name = fname 2420 2424 wildcard = "Text files (*.txt)|*.txt|"\ 2421 "CanSAS 1D files(*.xml)|*.xml" 2422 path = None 2425 "CanSAS 1D files (*.xml)|*.xml|"\ 2426 "NXcanSAS files (*.h5)|*.h5|" 2427 options = [".txt", ".xml",".h5"] 2423 2428 dlg = wx.FileDialog(self, "Choose a file", 2424 2429 self._default_save_location, … … 2430 2435 # This is MAC Fix 2431 2436 ext_num = dlg.GetFilterIndex() 2432 if ext_num == 0: 2433 ext_format = '.txt' 2434 else: 2435 ext_format = '.xml' 2437 2438 ext_format = options[ext_num] 2436 2439 path = os.path.splitext(path)[0] + ext_format 2437 2440 mypath = os.path.basename(path) 2438 2439 # Instantiate a loader 2440 loader = Loader() 2441 ext_format = ".txt" 2442 if os.path.splitext(mypath)[1].lower() == ext_format: 2441 fName = os.path.splitext(path)[0] + ext_format 2442 2443 if os.path.splitext(mypath)[1].lower() == options[0]: 2443 2444 # Make sure the ext included in the file name 2444 2445 # especially on MAC 2445 fName = os.path.splitext(path)[0] + ext_format2446 2446 self._onsaveTXT(data, fName) 2447 ext_format = ".xml" 2448 if os.path.splitext(mypath)[1].lower() == ext_format: 2447 elif os.path.splitext(mypath)[1].lower() == options[1]: 2449 2448 # Make sure the ext included in the file name 2450 2449 # especially on MAC 2451 fName = os.path.splitext(path)[0] + ext_format 2450 # Instantiate a loader 2451 loader = Loader() 2452 2452 loader.save(fName, data, ext_format) 2453 elif os.path.splitext(mypath)[1].lower() == options[2]: 2454 nxcansaswriter = NXcanSASWriter() 2455 nxcansaswriter.write([data], fName) 2453 2456 try: 2454 2457 self._default_save_location = os.path.dirname(path) … … 2477 2480 if has_errors: 2478 2481 if data.dx is not None and data.dx != []: 2479 out.write("<X> <Y> <dY><dX>\n")2482 out.write("<X>\t<Y>\t<dY>\t<dX>\n") 2480 2483 else: 2481 out.write("<X> <Y><dY>\n")2484 out.write("<X>\t<Y>\t<dY>\n") 2482 2485 else: 2483 out.write("<X> 2486 out.write("<X>\t<Y>\n") 2484 2487 2485 2488 for i in range(len(data.x)): … … 2525 2528 text += 'dY_min = %s: dY_max = %s\n' % (min(data.dy), max(data.dy)) 2526 2529 text += '\nData Points:\n' 2527 x_st = "X" 2530 text += "<index> \t<X> \t<Y> \t<dY> " 2531 text += "\t<dX>\n" if(data.dxl is not None and 2532 data.dxw is not None) else "\t<dXl> \t<dXw>\n" 2528 2533 for index in range(len(data.x)): 2529 2534 if data.dy is not None and len(data.dy) > index: … … 2536 2541 dx_val = 0.0 2537 2542 if data.dxl is not None and len(data.dxl) > index: 2538 if index == 0:2539 x_st = "Xl"2540 2543 dx_val = data.dxl[index] 2541 elif data.dxw is not None and len(data.dxw) > index: 2542 if index == 0: 2543 x_st = "Xw" 2544 dx_val = data.dxw[index] 2545 2546 if index == 0: 2547 text += "<index> \t<X> \t<Y> \t<dY> \t<d%s>\n" % x_st 2544 if data.dxw is not None and len(data.dxw) > index: 2545 dx_val = "%s \t%s" % (data.dxl[index], data.dxw[index]) 2546 2548 2547 text += "%s \t%s \t%s \t%s \t%s\n" % (index, 2549 2548 data.x[index], … … 2562 2561 """ 2563 2562 default_name = fname 2564 wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT" 2563 wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT|"\ 2564 "NXcanSAS files (*.h5)|*.h5|" 2565 2565 dlg = wx.FileDialog(self, "Choose a file", 2566 2566 self._default_save_location, … … 2574 2574 if ext_num == 0: 2575 2575 ext_format = '.dat' 2576 elif ext_num == 1: 2577 ext_format = '.h5' 2576 2578 else: 2577 2579 ext_format = '' … … 2581 2583 # Instantiate a loader 2582 2584 loader = Loader() 2583 2584 ext_format = ".dat" 2585 if os.path.splitext(mypath)[1].lower() == ext_format: 2585 if os.path.splitext(mypath)[1].lower() == '.dat': 2586 2586 # Make sure the ext included in the file name 2587 2587 # especially on MAC 2588 2588 fileName = os.path.splitext(path)[0] + ext_format 2589 2589 loader.save(fileName, data, ext_format) 2590 elif os.path.splitext(mypath)[1].lower() == '.h5': 2591 # Make sure the ext included in the file name 2592 # especially on MAC 2593 fileName = os.path.splitext(path)[0] + ext_format 2594 nxcansaswriter = NXcanSASWriter() 2595 nxcansaswriter.write([data], fileName) 2590 2596 try: 2591 2597 self._default_save_location = os.path.dirname(path)
Note: See TracChangeset
for help on using the changeset viewer.