Changeset dcd6efd in sasview for src/sas/sasgui/guiframe/gui_manager.py
- Timestamp:
- Jan 2, 2019 1:57:45 PM (5 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249
- Children:
- ef74a8b, a13c41b, 462e019
- Parents:
- cb9640f (diff), d96744de (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. - git-author:
- Paul Butler <butlerpd@…> (01/02/19 13:57:45)
- git-committer:
- GitHub <noreply@…> (01/02/19 13:57:45)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/gui_manager.py
r47be5a1 rdcd6efd 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 … … 2407 2408 default_name = fname 2408 2409 wildcard = "Text files (*.txt)|*.txt|"\ 2409 "CanSAS 1D files(*.xml)|*.xml" 2410 path = None 2410 "CanSAS 1D files (*.xml)|*.xml|"\ 2411 "NXcanSAS files (*.h5)|*.h5|" 2412 options = [".txt", ".xml",".h5"] 2411 2413 dlg = wx.FileDialog(self, "Choose a file", 2412 2414 self._default_save_location, … … 2418 2420 # This is MAC Fix 2419 2421 ext_num = dlg.GetFilterIndex() 2420 if ext_num == 0: 2421 ext_format = '.txt' 2422 else: 2423 ext_format = '.xml' 2422 2423 ext_format = options[ext_num] 2424 2424 path = os.path.splitext(path)[0] + ext_format 2425 2425 mypath = os.path.basename(path) 2426 2427 # Instantiate a loader 2428 loader = Loader() 2429 ext_format = ".txt" 2430 if os.path.splitext(mypath)[1].lower() == ext_format: 2426 fName = os.path.splitext(path)[0] + ext_format 2427 2428 if os.path.splitext(mypath)[1].lower() == options[0]: 2431 2429 # Make sure the ext included in the file name 2432 2430 # especially on MAC 2433 fName = os.path.splitext(path)[0] + ext_format2434 2431 self._onsaveTXT(data, fName) 2435 ext_format = ".xml" 2436 if os.path.splitext(mypath)[1].lower() == ext_format: 2432 elif os.path.splitext(mypath)[1].lower() == options[1]: 2437 2433 # Make sure the ext included in the file name 2438 2434 # especially on MAC 2439 fName = os.path.splitext(path)[0] + ext_format 2435 # Instantiate a loader 2436 loader = Loader() 2440 2437 loader.save(fName, data, ext_format) 2438 elif os.path.splitext(mypath)[1].lower() == options[2]: 2439 nxcansaswriter = NXcanSASWriter() 2440 nxcansaswriter.write([data], fName) 2441 2441 try: 2442 2442 self._default_save_location = os.path.dirname(path) … … 2465 2465 if has_errors: 2466 2466 if data.dx is not None and data.dx != []: 2467 out.write("<X> <Y> <dY><dX>\n")2467 out.write("<X>\t<Y>\t<dY>\t<dX>\n") 2468 2468 else: 2469 out.write("<X> <Y><dY>\n")2469 out.write("<X>\t<Y>\t<dY>\n") 2470 2470 else: 2471 out.write("<X> 2471 out.write("<X>\t<Y>\n") 2472 2472 2473 2473 for i in range(len(data.x)): … … 2513 2513 text += 'dY_min = %s: dY_max = %s\n' % (min(data.dy), max(data.dy)) 2514 2514 text += '\nData Points:\n' 2515 x_st = "X" 2515 text += "<index> \t<X> \t<Y> \t<dY> " 2516 text += "\t<dXl> \t<dXw>\n" if(data.dxl is not None and 2517 data.dxw is not None) else "\t<dX>\n" 2516 2518 for index in range(len(data.x)): 2517 2519 if data.dy is not None and len(data.dy) > index: … … 2524 2526 dx_val = 0.0 2525 2527 if data.dxl is not None and len(data.dxl) > index: 2526 if index == 0:2527 x_st = "Xl"2528 2528 dx_val = data.dxl[index] 2529 elif data.dxw is not None and len(data.dxw) > index: 2530 if index == 0: 2531 x_st = "Xw" 2532 dx_val = data.dxw[index] 2533 2534 if index == 0: 2535 text += "<index> \t<X> \t<Y> \t<dY> \t<d%s>\n" % x_st 2529 if data.dxw is not None and len(data.dxw) > index: 2530 dx_val = "%s \t%s" % (data.dxl[index], data.dxw[index]) 2531 2536 2532 text += "%s \t%s \t%s \t%s \t%s\n" % (index, 2537 2533 data.x[index], … … 2550 2546 """ 2551 2547 default_name = fname 2552 wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT" 2548 wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT|"\ 2549 "NXcanSAS files (*.h5)|*.h5|" 2553 2550 dlg = wx.FileDialog(self, "Choose a file", 2554 2551 self._default_save_location, … … 2562 2559 if ext_num == 0: 2563 2560 ext_format = '.dat' 2561 elif ext_num == 1: 2562 ext_format = '.h5' 2564 2563 else: 2565 2564 ext_format = '' … … 2569 2568 # Instantiate a loader 2570 2569 loader = Loader() 2571 2572 ext_format = ".dat" 2573 if os.path.splitext(mypath)[1].lower() == ext_format: 2570 ext = os.path.splitext(mypath)[1].lower() 2571 if ext == '.dat': 2574 2572 # Make sure the ext included in the file name 2575 2573 # especially on MAC 2576 2574 fileName = os.path.splitext(path)[0] + ext_format 2577 2575 loader.save(fileName, data, ext_format) 2576 elif ext == '.h5': 2577 # Make sure the ext included in the file name 2578 # especially on MAC 2579 fileName = os.path.splitext(path)[0] + ext_format 2580 nxcansaswriter = NXcanSASWriter() 2581 nxcansaswriter.write([data], fileName) 2578 2582 try: 2579 2583 self._default_save_location = os.path.dirname(path)
Note: See TracChangeset
for help on using the changeset viewer.