Changeset 82d88d5 in sasview for src/sas/sasgui/guiframe/gui_manager.py
- Timestamp:
- Mar 6, 2019 6:18:09 PM (5 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1249
- Children:
- f923967
- Parents:
- cb64d86 (diff), f205d3a (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/sasgui/guiframe/gui_manager.py
r5251ec6 r82d88d5 48 48 from sas.sasgui.guiframe.CategoryManager import CategoryManager 49 49 from sas.sascalc.dataloader.loader import Loader 50 from sas.sascalc.file_converter.nxcansas_writer import NXcanSASWriter 50 51 from sas.sasgui.guiframe.proxy import Connection 51 52 … … 64 65 SPLASH_SCREEN_HEIGHT = config.SPLASH_SCREEN_HEIGHT 65 66 SS_MAX_DISPLAY_TIME = config.SS_MAX_DISPLAY_TIME 66 if not WELCOME_PANEL_ON: 67 WELCOME_PANEL_SHOW = False 67 68 def custom_value(name, default=None): 69 """ 70 Fetch a config value from custom_config. Fallback to config, and then 71 to default if it doesn't exist in config. 72 """ 73 default = getattr(config, name, default) 74 return getattr(custom_config, name, default) 75 76 # Custom config values in the order they appear. 77 DATAPANEL_WIDTH = custom_value('DATAPANEL_WIDTH', -1) 78 CLEANUP_PLOT = custom_value('CLEANUP_PLOT', False) 79 FIXED_PANEL = custom_value('FIXED_PANEL', True) 80 PLOPANEL_WIDTH = custom_value('PLOPANEL_WIDTH', -1) 81 DATALOADER_SHOW = custom_value('DATALOADER_SHOW', True) 82 GUIFRAME_HEIGHT = custom_value('GUIFRAME_HEIGHT', -1) 83 GUIFRAME_WIDTH = custom_value('GUIFRAME_WIDTH', -1) 84 CONTROL_WIDTH = custom_value('CONTROL_WIDTH', -1) 85 CONTROL_HEIGHT = custom_value('CONTROL_HEIGHT', -1) 86 open_folder = custom_value('DEFAULT_OPEN_FOLDER', None) 87 if open_folder is not None and os.path.isdir(open_folder): 88 DEFAULT_OPEN_FOLDER = os.path.abspath(open_folder) 68 89 else: 69 WELCOME_PANEL_SHOW = True70 try:71 DATALOADER_SHOW = custom_config.DATALOADER_SHOW72 TOOLBAR_SHOW = custom_config.TOOLBAR_SHOW73 FIXED_PANEL = custom_config.FIXED_PANEL74 if WELCOME_PANEL_ON:75 WELCOME_PANEL_SHOW = custom_config.WELCOME_PANEL_SHOW76 PLOPANEL_WIDTH = custom_config.PLOPANEL_WIDTH77 DATAPANEL_WIDTH = custom_config.DATAPANEL_WIDTH78 GUIFRAME_WIDTH = custom_config.GUIFRAME_WIDTH79 GUIFRAME_HEIGHT = custom_config.GUIFRAME_HEIGHT80 CONTROL_WIDTH = custom_config.CONTROL_WIDTH81 CONTROL_HEIGHT = custom_config.CONTROL_HEIGHT82 DEFAULT_PERSPECTIVE = custom_config.DEFAULT_PERSPECTIVE83 CLEANUP_PLOT = custom_config.CLEANUP_PLOT84 # custom open_path85 open_folder = custom_config.DEFAULT_OPEN_FOLDER86 if open_folder is not None and os.path.isdir(open_folder):87 DEFAULT_OPEN_FOLDER = os.path.abspath(open_folder)88 else:89 DEFAULT_OPEN_FOLDER = get_app_dir()90 SAS_OPENCL = custom_config.SAS_OPENCL91 except:92 DATALOADER_SHOW = True93 TOOLBAR_SHOW = True94 FIXED_PANEL = True95 WELCOME_PANEL_SHOW = False96 PLOPANEL_WIDTH = config.PLOPANEL_WIDTH97 DATAPANEL_WIDTH = config.DATAPANEL_WIDTH98 GUIFRAME_WIDTH = config.GUIFRAME_WIDTH99 GUIFRAME_HEIGHT = config.GUIFRAME_HEIGHT100 CONTROL_WIDTH = -1101 CONTROL_HEIGHT = -1102 DEFAULT_PERSPECTIVE = None103 CLEANUP_PLOT = False104 90 DEFAULT_OPEN_FOLDER = get_app_dir() 105 DEFAULT_OPEN_FOLDER = PATH_APP 106 SAS_OPENCL = None 91 WELCOME_PANEL_SHOW = (custom_value('WELCOME_PANEL_SHOW', False) 92 if WELCOME_PANEL_ON else False) 93 TOOLBAR_SHOW = custom_value('TOOLBAR_SHOW', True) 94 DEFAULT_PERSPECTIVE = custom_value('DEFAULT_PERSPECTIVE', 'Fitting') 95 SAS_OPENCL = custom_value('SAS_OPENCL', 'None') 96 107 97 DEFAULT_STYLE = config.DEFAULT_STYLE 108 109 98 PLUGIN_STATE_EXTENSIONS = config.PLUGIN_STATE_EXTENSIONS 110 99 OPEN_SAVE_MENU = config.OPEN_SAVE_PROJECT_MENU … … 2420 2409 default_name = fname 2421 2410 wildcard = "Text files (*.txt)|*.txt|"\ 2422 "CanSAS 1D files(*.xml)|*.xml" 2423 path = None 2411 "CanSAS 1D files (*.xml)|*.xml|"\ 2412 "NXcanSAS files (*.h5)|*.h5|" 2413 options = [".txt", ".xml",".h5"] 2424 2414 dlg = wx.FileDialog(self, "Choose a file", 2425 2415 self._default_save_location, … … 2431 2421 # This is MAC Fix 2432 2422 ext_num = dlg.GetFilterIndex() 2433 if ext_num == 0: 2434 ext_format = '.txt' 2435 else: 2436 ext_format = '.xml' 2423 2424 ext_format = options[ext_num] 2437 2425 path = os.path.splitext(path)[0] + ext_format 2438 2426 mypath = os.path.basename(path) 2439 2440 # Instantiate a loader 2441 loader = Loader() 2442 ext_format = ".txt" 2443 if os.path.splitext(mypath)[1].lower() == ext_format: 2427 fName = os.path.splitext(path)[0] + ext_format 2428 2429 if os.path.splitext(mypath)[1].lower() == options[0]: 2444 2430 # Make sure the ext included in the file name 2445 2431 # especially on MAC 2446 fName = os.path.splitext(path)[0] + ext_format2447 2432 self._onsaveTXT(data, fName) 2448 ext_format = ".xml" 2449 if os.path.splitext(mypath)[1].lower() == ext_format: 2433 elif os.path.splitext(mypath)[1].lower() == options[1]: 2450 2434 # Make sure the ext included in the file name 2451 2435 # especially on MAC 2452 fName = os.path.splitext(path)[0] + ext_format 2436 # Instantiate a loader 2437 loader = Loader() 2453 2438 loader.save(fName, data, ext_format) 2439 elif os.path.splitext(mypath)[1].lower() == options[2]: 2440 nxcansaswriter = NXcanSASWriter() 2441 nxcansaswriter.write([data], fName) 2454 2442 try: 2455 2443 self._default_save_location = os.path.dirname(path) … … 2478 2466 if has_errors: 2479 2467 if data.dx is not None and data.dx != []: 2480 out.write("<X> <Y> <dY><dX>\n")2468 out.write("<X>\t<Y>\t<dY>\t<dX>\n") 2481 2469 else: 2482 out.write("<X> <Y><dY>\n")2470 out.write("<X>\t<Y>\t<dY>\n") 2483 2471 else: 2484 out.write("<X> 2472 out.write("<X>\t<Y>\n") 2485 2473 2486 2474 for i in range(len(data.x)): … … 2526 2514 text += 'dY_min = %s: dY_max = %s\n' % (min(data.dy), max(data.dy)) 2527 2515 text += '\nData Points:\n' 2528 x_st = "X" 2516 text += "<index> \t<X> \t<Y> \t<dY> " 2517 text += "\t<dXl> \t<dXw>\n" if(data.dxl is not None and 2518 data.dxw is not None) else "\t<dX>\n" 2529 2519 for index in range(len(data.x)): 2530 2520 if data.dy is not None and len(data.dy) > index: … … 2537 2527 dx_val = 0.0 2538 2528 if data.dxl is not None and len(data.dxl) > index: 2539 if index == 0:2540 x_st = "Xl"2541 2529 dx_val = data.dxl[index] 2542 elif data.dxw is not None and len(data.dxw) > index: 2543 if index == 0: 2544 x_st = "Xw" 2545 dx_val = data.dxw[index] 2546 2547 if index == 0: 2548 text += "<index> \t<X> \t<Y> \t<dY> \t<d%s>\n" % x_st 2530 if data.dxw is not None and len(data.dxw) > index: 2531 dx_val = "%s \t%s" % (data.dxl[index], data.dxw[index]) 2532 2549 2533 text += "%s \t%s \t%s \t%s \t%s\n" % (index, 2550 2534 data.x[index], … … 2563 2547 """ 2564 2548 default_name = fname 2565 wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT" 2549 wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT|"\ 2550 "NXcanSAS files (*.h5)|*.h5|" 2566 2551 dlg = wx.FileDialog(self, "Choose a file", 2567 2552 self._default_save_location, … … 2575 2560 if ext_num == 0: 2576 2561 ext_format = '.dat' 2562 elif ext_num == 1: 2563 ext_format = '.h5' 2577 2564 else: 2578 2565 ext_format = '' … … 2582 2569 # Instantiate a loader 2583 2570 loader = Loader() 2584 2585 ext_format = ".dat" 2586 if os.path.splitext(mypath)[1].lower() == ext_format: 2571 ext = os.path.splitext(mypath)[1].lower() 2572 if ext == '.dat': 2587 2573 # Make sure the ext included in the file name 2588 2574 # especially on MAC 2589 2575 fileName = os.path.splitext(path)[0] + ext_format 2590 2576 loader.save(fileName, data, ext_format) 2577 elif ext == '.h5': 2578 # Make sure the ext included in the file name 2579 # especially on MAC 2580 fileName = os.path.splitext(path)[0] + ext_format 2581 nxcansaswriter = NXcanSASWriter() 2582 nxcansaswriter.write([data], fileName) 2591 2583 try: 2592 2584 self._default_save_location = os.path.dirname(path)
Note: See TracChangeset
for help on using the changeset viewer.