Changeset dec793e in sasview
- 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
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
invariantview/media/report_template.html
rb281210 rdec793e 43 43 <tr> 44 44 <td width=170 valign=top > 45 <p class=MsoNormal > porod 45 <p class=MsoNormal > porod constant</p> 46 46 </td> 47 47 <td width=213 valign=top > -
invariantview/perspectives/invariant/report_dialog.py
rcf9b6950 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 31 32 33 32 ISMAC = True 33 34 34 class ReportDialog(wx.Dialog): 35 35 """ … … 53 53 # font size 54 54 self.SetWindowVariant(variant=FONT_VARIANT) 55 56 # check if tit is MAC 57 self.is_mac = ISMAC 58 55 59 # report string 56 60 self.report_list = list … … 59 63 # layout 60 64 self._setup_layout() 65 # wild card 66 # pdf supporting only on MAC 67 if self.is_mac: 68 self.wild_card = ' PDF files (*.pdf)|*.pdf|' 69 else: 70 self.wild_card = '' 71 self.wild_card += 'HTML files (*.html)|*.html|' 72 self.wild_card += 'Text files (*.txt)|*.txt' 73 74 61 75 62 76 def _setup_layout(self): … … 109 123 self.Centre() 110 124 self.Show(True) 111 125 112 126 113 127 def onSave(self, event=None): … … 117 131 #todo: complete saving fig file and as a txt file 118 132 dlg = wx.FileDialog(self, "Choose a file", 119 wildcard='HTML files (*.html)|*.html|'+ 120 'Text files (*.txt)|*.txt', 133 wildcard=self.wild_card, 121 134 style=wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR) 122 135 dlg.SetFilterIndex(0) #Set .html files to be default … … 125 138 dlg.Destroy() 126 139 return 127 140 128 141 fName = dlg.GetPath() 129 ext_num = dlg.GetFilterIndex() 130 142 ext_num = dlg.GetFilterIndex() 143 # index correction 144 if not self.is_mac: 145 ind_cor = 1 146 else: 147 ind_cor = 0 131 148 #set file extensions 132 if ext_num == 0: 149 if ext_num == (0 + 2 * ind_cor): 150 # TODO: Sort this case out 151 ext = '.pdf' 152 img_ext = '_img.png' 153 fName = os.path.splitext(fName)[0] + ext 154 dlg.Destroy() 155 156 #pic (png) file path/name 157 pic_fname = os.path.splitext(fName)[0] + img_ext 158 # save the image for use with pdf writer 159 self.report_list[2].savefig(pic_fname) 160 161 # put the image file path in the html data 162 html = self.report_list[0] % str(pic_fname) 163 164 # make/open file in case of absence 165 f = open(fName, 'w') 166 f.close() 167 # write pdf as a pdf file 168 pdf = self.HTML2PDF(data=html, filename=fName) 169 170 #open pdf 171 if pdf: 172 os.startfile(str(fName)) 173 #delete image file 174 os.remove(pic_fname) 175 return 176 elif ext_num == (1 - ind_cor): 133 177 ext = '.html' 134 178 img_ext = '_img4html.png' 135 179 report_frame = self.report_list[0] 136 elif ext_num == 1:180 elif ext_num == (2 - ind_cor): 137 181 ext = '.txt' 138 182 # changing the image extension actually changes the image … … 142 186 else: 143 187 return 144 188 145 189 #file name 146 190 fName = os.path.splitext(fName)[0] + ext … … 149 193 pic_fname = os.path.splitext(fName)[0] + img_ext 150 194 #put the image path in html string 151 if ext_num == 0:195 if ext_num == (1 - ind_cor): 152 196 report = report_frame % pic_fname 197 153 198 f = open(fName, 'w') 154 199 f.write(report) -
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.