Changeset 78a205a in sasview for src/sas/perspectives/invariant/report_dialog.py
- Timestamp:
- Mar 5, 2015 10:29:42 AM (10 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:
- dca6188
- Parents:
- 74f419d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/perspectives/invariant/report_dialog.py
re8bb5b6 r78a205a 1 1 2 2 ################################################################################ 3 # This software was developed by the University of Tennessee as part of the4 # Distributed Data Analysis of Neutron Scattering Experiments (DANSE)5 # project funded by the US National Science Foundation.3 # This software was developed by the University of Tennessee as part of the 4 # Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 5 # project funded by the US National Science Foundation. 6 6 # 7 # See the license text in license.txt7 # See the license text in license.txt 8 8 # 9 # copyright 2009, University of Tennessee9 # copyright 2009, University of Tennessee 10 10 ################################################################################ 11 11 12 12 """ 13 Dialog report panel to show and summarize the results of 13 Dialog report panel to show and summarize the results of 14 14 the invariant calculation. 15 15 """ 16 16 import wx 17 17 import os 18 import wx.html as html 19 18 import sys 19 import logging 20 20 21 from sas.guiframe.report_dialog import BaseReportDialog 21 22 22 23 class ReportDialog(BaseReportDialog): 23 24 """ 24 The report dialog box. 25 The report dialog box. 25 26 """ 26 27 def __init__(self, 27 28 def __init__(self, report_list, *args, **kwds): 28 29 """ 29 30 Initialization. The parameters added to Dialog are: 30 31 31 32 :param report_list: list of html_str, text_str, image 32 33 from invariant_state … … 46 47 Save 47 48 """ 48 # todo: complete saving fig file and as a txt file49 # todo: complete saving fig file and as a txt file 49 50 dlg = wx.FileDialog(self, "Choose a file", 50 51 wildcard=self.wild_card, 51 style=wx.SAVE |wx.OVERWRITE_PROMPT|wx.CHANGE_DIR)52 dlg.SetFilterIndex(0) #Set .html files to be default52 style=wx.SAVE | wx.OVERWRITE_PROMPT | wx.CHANGE_DIR) 53 dlg.SetFilterIndex(0) # Set .html files to be default 53 54 54 55 if dlg.ShowModal() != wx.ID_OK: … … 57 58 58 59 fName = dlg.GetPath() 59 ext_num = dlg.GetFilterIndex() 60 # set file extensions60 ext_num = dlg.GetFilterIndex() 61 # set file extensions 61 62 if ext_num == (0 + 2 * self.index_offset): 62 63 # TODO: Sort this case out … … 66 67 dlg.Destroy() 67 68 68 # pic (png) file path/name69 # pic (png) file path/name 69 70 pic_fname = os.path.splitext(fName)[0] + img_ext 70 71 # save the image for use with pdf writer … … 73 74 # put the image file path in the html data 74 75 html = self.report_list[0] % str(pic_fname) 75 76 76 77 # make/open file in case of absence 77 78 f = open(fName, 'w') … … 79 80 # write pdf as a pdf file 80 81 pdf = self.HTML2PDF(data=html, filename=fName) 81 82 # open pdf82 83 # open pdf 83 84 if pdf: 84 85 try: 85 # Windows86 # Windows 86 87 os.startfile(str(fName)) 87 88 except: 88 89 try: 89 # Mac90 os.system("open %s" % fName)90 # Mac 91 os.system("open %s" % fName) 91 92 except: 92 # DO not open93 pass94 # delete image file93 # DO not open 94 logging.error("Could not open file: %s" % sys.exc_value) 95 # delete image file 95 96 os.remove(pic_fname) 96 97 return … … 100 101 report_frame = self.report_list[0] 101 102 elif ext_num == (2 - self.index_offset): 102 ext = '.txt' 103 ext = '.txt' 103 104 # changing the image extension actually changes the image 104 105 # format on saving … … 108 109 return 109 110 110 # file name111 # file name 111 112 fName = os.path.splitext(fName)[0] + ext 112 113 dlg.Destroy() 113 # pic (png) file path/name114 # pic (png) file path/name 114 115 pic_fname = os.path.splitext(fName)[0] + img_ext 115 # put the image path in html string116 # put the image path in html string 116 117 if ext_num == (1 - self.index_offset): 117 118 report = report_frame % os.path.basename(pic_fname) … … 120 121 f.write(report) 121 122 f.close() 122 # save png file using pic_fname123 # save png file using pic_fname 123 124 self.report_list[2].savefig(pic_fname) 124
Note: See TracChangeset
for help on using the changeset viewer.