Changeset 850525c in sasview for sansguiframe/src
- Timestamp:
- Sep 9, 2011 7:24:12 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:
- 06772f6
- Parents:
- 6446f87
- Location:
- sansguiframe/src/sans/guiframe
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sansguiframe/src/sans/guiframe/data_processor.py
r73197d0 r850525c 6 6 import math 7 7 import re 8 import os 8 9 import sys 9 10 import copy … … 625 626 Allow to select where the result of batch will be displayed or stored 626 627 """ 627 def __init__(self, parent=None, data=None, *args, **kwds): 628 def __init__(self, parent=None, data=None, file_name="", 629 details="", *args, **kwds): 628 630 """ 629 631 :param parent: Window instantiating this dialog … … 631 633 application. 632 634 """ 633 kwds['style'] = wx.CAPTION|wx.SYSTEM_MENU635 #kwds['style'] = wx.CAPTION|wx.SYSTEM_MENU 634 636 wx.Dialog.__init__(self, parent, *args, **kwds) 635 637 self.parent = parent 638 self.file_name = file_name 639 self.details = details 636 640 self.data = data 637 641 self.flag = 1 … … 667 671 self.external_app_selected.SetValue(False) 668 672 self.save_to_file.SetValue(False) 669 670 673 button_OK = wx.Button(self, wx.ID_OK, "Ok") 671 674 button_OK.SetFocus() … … 700 703 """ 701 704 if self.save_to_file.GetValue(): 702 self.flag = 3 703 if self.parent is not None and self.data is not None: 704 self.parent.save_batch_into_file(self.data) 705 elif self.local_app_selected.GetValue(): 705 reader, ext = os.path.splitext(self.file_name) 706 path = None 707 location = os.getcwd() 708 if self.parent is not None: 709 location = self.parent._default_save_location 710 dlg = wx.FileDialog(self, "Save Project file", 711 location, self.file_name, ext, wx.SAVE) 712 path = None 713 if dlg.ShowModal() == wx.ID_OK: 714 path = dlg.GetPath() 715 if self.parent is not None: 716 self.parent._default_save_location = os.path.dirname(path) 717 dlg.Destroy() 718 if path != None: 719 if self.parent is not None and self.data is not None: 720 self.parent.write_batch_output(data=self.data, 721 file_name=path, 722 details=self.details) 723 724 if self.local_app_selected.GetValue(): 706 725 self.flag = 1 707 726 else: 708 727 self.flag = 2 709 728 return self.flag 729 730 def save_file(self): 731 """ 732 Save inot file 733 """ 734 710 735 711 736 -
sansguiframe/src/sans/guiframe/gui_manager.py
r73197d0 r850525c 16 16 import sys 17 17 import xml 18 import time 18 19 import py_compile 19 20 # Try to find a local config … … 22 23 warnings.simplefilter("ignore") 23 24 import logging 25 import win32com 24 26 25 27 from sans.guiframe.events import EVT_STATUS … … 284 286 self.setup_custom_conf() 285 287 286 def on_set_batch_result(self, data, name):288 def on_set_batch_result(self, data, plugin_name): 287 289 """ 288 290 Display data into a grid in batch mode and show the grid 289 291 """ 292 t = time.localtime(time.time()) 293 time_str = time.strftime("%b %d %H;%M of %Y", t) 294 name = "Batch" + time_str 295 details = "File Generated by %s : %s.\n" % (APPLICATION_NAME, 296 str(plugin_name)) 297 details += "on %s.\n" % time_str 298 ext = ".csv" 299 file_name = "Batch_" + str(plugin_name)+ "_" + time_str + ext 290 300 #Neeed to save configuration for later 291 dlg = BatchOutputDialog(self, data) 301 dlg = BatchOutputDialog(parent=self, data=data, 302 file_name=file_name, 303 details=details) 292 304 flag = None 293 305 if dlg.ShowModal() == wx.ID_OK: 294 flag = dlg. onselect()306 flag = dlg.flag 295 307 dlg.Destroy() 296 308 if flag == 1: … … 298 310 self.batch_frame.Show(True) 299 311 elif flag == 2: 300 self.deplay_in_external_app(data) 301 302 def save_batch_into_file(self, data): 303 """ 304 Save data into file. default extension is .csv 305 """ 306 def deplay_in_external_app(self, data): 312 if not os.path.exists(file_name): 313 self.write_batch_output(data=data, file_name=file_name, 314 details=details) 315 self.deplay_in_external_app(data=data, file_name=file_name) 316 317 def write_batch_output(self, data, file_name, details=""): 318 """ 319 Helper to write result from batch into cvs file 320 """ 321 322 if data is None or file_name is None or file_name.strip() == "": 323 return 324 _, ext = os.path.splitext(file_name) 325 326 fd = open(file_name, 'w') 327 separator = "\t" 328 if ext.lower() == ".csv": 329 separator = "," 330 fd.write(str(details)) 331 fd.write(separator) 332 fd.write('\n') 333 for col_name in data.keys(): 334 fd.write(str(col_name)) 335 fd.write(separator) 336 fd.write('\n') 337 max_list = [len(value) for value in data.values()] 338 if len(max_list) == 0: 339 return 340 max_index = max(max_list) 341 index = 0 342 while(index < max_index): 343 for value_list in data.values(): 344 if index < len(value_list): 345 fd.write(str(value_list[index])) 346 fd.write(separator) 347 else: 348 fd.write('') 349 fd.write(separator) 350 fd.write('\n') 351 index += 1 352 fd.close() 353 354 def deplay_in_external_app(self, data, file_name): 307 355 """ 308 356 Display data in the another application , by default Excel 309 357 """ 358 310 359 def on_batch_selection(self, event): 311 360 """
Note: See TracChangeset
for help on using the changeset viewer.