Changeset dec793e in sasview for sansview/perspectives
- Timestamp:
- Apr 5, 2011 7:32:45 PM (14 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:
- 4b470cf
- Parents:
- 8da09f4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/report_dialog.py
r2296316 rdec793e 24 24 PANEL_HEIGHT = 700 25 25 FONT_VARIANT = 0 26 ISMAC = False 26 27 else: 27 28 _STATICBOX_WIDTH = 480 … … 29 30 PANEL_HEIGHT = 700 30 31 FONT_VARIANT = 1 32 ISMAC = True 31 33 32 34 … … 53 55 # font size 54 56 self.SetWindowVariant(variant=FONT_VARIANT) 57 # check if tit is MAC 58 self.is_mac = ISMAC 55 59 # report string 56 60 self.report_list = list … … 64 68 "memory:img_fit0.png" 65 69 elif len(list[2]) == 2: 66 #print "self.report_list[0]",self.report_list[0]67 70 self.report_html = self.report_list[0] % \ 68 71 ("memory:img_fit0.png", … … 133 136 Save 134 137 """ 138 # pdf supporting only on MAC, not on exe 139 if self.is_mac: 140 wild_card = ' PDF files (*.pdf)|*.pdf|' 141 ind_cor = 0 142 else: 143 wild_card = '' 144 ind_cor = 1 145 wild_card += 'HTML files (*.html)|*.html|' 146 wild_card += 'Text files (*.txt)|*.txt' 147 135 148 #todo: complete saving fig file and as a txt file 136 149 dlg = wx.FileDialog(self, "Choose a file", 137 wildcard='HTML files (*.html)|*.html|'+ 138 'Text files (*.txt)|*.txt', 150 wildcard=wild_card, 139 151 style=wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR) 140 152 dlg.SetFilterIndex(0) #Set .html files to be default … … 149 161 #set file extensions 150 162 img_ext = [] 151 if ext_num == 0: 163 pic_fname = [] 164 #PDF 165 if ext_num == (0 + 2 * ind_cor): 166 # TODO: Sort this case out 167 ext = '.pdf' 168 169 fName = os.path.splitext(fName)[0] + ext 170 dlg.Destroy() 171 #pic (png) file path/name 172 for num in range(self.nimages): 173 im_ext = '_img%s.png' % num 174 #img_ext.append(im_ext) 175 pic_name = os.path.splitext(fName)[0] + im_ext 176 pic_fname.append(pic_name) 177 # save the image for use with pdf writer 178 self.report_list[2][num].savefig(pic_name) 179 180 #put the image path in html string 181 report_frame = self.report_list[0] 182 #put image name strings into the html file 183 #Note:The str for pic_fname shouldn't be removed. 184 if self.nimages == 1: 185 html = report_frame % str(pic_fname[0]) 186 elif self.nimages == 2: 187 html = report_frame % (str(pic_fname[0]), str(pic_fname[1])) 188 elif self.nimages == 3: 189 html = report_frame % (str(pic_fname[0]), str(pic_fname[1]), 190 str(pic_fname[2])) 191 192 # make/open file in case of absence 193 f = open(fName, 'w') 194 f.close() 195 # write pdf as a pdf file 196 pdf = self.HTML2PDF(data=html, filename=fName) 197 198 #open pdf 199 if pdf: 200 os.startfile(str(fName)) 201 #delete image file 202 for num in range(self.nimages): 203 os.remove(pic_fname[num]) 204 return 205 #HTML + png(graph) 206 elif ext_num == (1 - ind_cor): 152 207 ext = '.html' 153 208 for num in range(self.nimages): 154 209 img_ext.append('_img4html%s.png' % num) 155 210 report_frame = self.report_list[0] 156 elif ext_num == 1: 211 #TEXT + pdf(graph) 212 elif ext_num == (2 - ind_cor): 157 213 ext = '.txt' 158 214 # changing the image extension actually changes the image … … 167 223 fName = os.path.splitext(fName)[0] + ext 168 224 dlg.Destroy() 169 pic_fname = []225 170 226 #pic (png) file path/name 171 227 for num in range(self.nimages): … … 173 229 pic_fname.append(pic_name) 174 230 #put the image path in html string 175 if ext_num == 0:231 if ext_num == (1 - ind_cor): 176 232 if self.nimages == 1: 177 233 report = report_frame % pic_fname[0] … … 234 290 # pisa requires some extra packages, see their web-site 235 291 pdf = pisa.CreatePDF(data, f) 292 236 293 # close the file here otherwise it will be open until quitting 237 294 #the application.
Note: See TracChangeset
for help on using the changeset viewer.