Changeset b281210 in sasview for invariantview/perspectives/invariant
- Timestamp:
- Jul 26, 2010 7:27:38 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:
- cb274d9e
- Parents:
- cef847c
- Location:
- invariantview/perspectives/invariant
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
invariantview/perspectives/invariant/invariant_state.py
ra94c4e1 rb281210 102 102 self.template_str = html_template.read() 103 103 self.report_str = self.template_str 104 #self.report_str_save = None 104 105 html_template.close() 105 106 … … 211 212 except: 212 213 pass 213 state += "(%s %s)"%(format_number(value),' %')214 state += "(%s %s)"%(format_number(value),'o/o') 214 215 # Outputs 215 216 else: … … 464 465 bool_0 = extra[0].split("=") 465 466 bool_1 = extra[1].split("=") 466 s_7 = " "+bool_0[0]+" = "+bool_0[1]467 s_8 = " "+bool_1[0]+" = "+bool_1[1]467 s_7 = " "+bool_0[0]+"Q region = "+bool_0[1] 468 s_8 = " "+bool_1[0]+"Q region = "+bool_1[1] 468 469 elif item[0]=="npts low": 469 470 s_9 = item[1] … … 491 492 # make plot image 492 493 self.set_plot_state(extra_high=bool_0[1],extra_low=bool_1[1]) 493 494 494 # get ready for report with setting all the html strings 495 self.report_str = str(self.template_str)% (s_1,s_2,s_3,s_4,s_5,s_6,s_7,s_8,s_9,s_10,s_11,s_12,s_13,s_14,s_15,s_16,s_17,s_18,self.file,self.wximbmp)496 497 495 self.report_str = str(self.template_str)% (s_1,s_2,s_3,s_4,s_5,s_6,s_7,s_8,s_9,s_10,s_11,s_12,s_13,s_14,s_15,s_16,s_17,s_18,self.file,"%s") 496 497 498 498 def set_saved_state(self, name, value): 499 499 """ … … 577 577 578 578 self.wximbmp = 'memory:img_inv.png' 579 579 self.image = img 580 580 581 581 class Reader(CansasReader): -
invariantview/perspectives/invariant/report_dialog.py
ra94c4e1 rb281210 19 19 import wx.html as html 20 20 import Image 21 21 22 if sys.platform.count("win32")>0: 22 23 _STATICBOX_WIDTH = 450 … … 37 38 """ 38 39 39 def __init__(self, string, *args, **kwds):40 def __init__(self, list, *args, **kwds): 40 41 """ 41 42 Initialization. The parameters added to Dialog are: 42 43 43 :param string: report_stringfrom invariant_state44 :param list: report_list (list of html_str, text_str, image) from invariant_state 44 45 """ 45 46 kwds["style"] = wx.RESIZE_BORDER|wx.DEFAULT_DIALOG_STYLE … … 53 54 self.SetWindowVariant(variant=FONT_VARIANT) 54 55 # report string 55 self.report_string =string 56 self.report_list =list 57 # put image path in the report string 58 self.report_html = self.report_list[0]% "memory:img_inv.png" 56 59 # layout 57 60 self._setup_layout() … … 61 64 Set up layout 62 65 """ 63 # panel for buttons64 bpanel = wx.Panel(self, -1)65 66 hbox = wx.BoxSizer(wx.HORIZONTAL) 66 67 67 68 # buttons 68 69 id = wx.NewId() 69 button_save = wx.Button(self, id, "Save" )70 button_save = wx.Button(self, id, "Save" ) 70 71 button_save.SetToolTipString("Save this report.") 71 72 button_save.Bind(wx.EVT_BUTTON, self.onSave, id = button_save.GetId()) … … 84 85 hbox.Add(button_print) 85 86 87 id = wx.ID_OK 88 button_close = wx.Button(self, id, "Close") 89 button_close.SetToolTipString("Close this report window.") 90 hbox.Add((5,10), 1 , wx.EXPAND|wx.ADJUST_MINSIZE,0) 91 hbox.Add(button_close) 92 button_close.SetFocus() 93 86 94 87 95 # panel for report page … … 91 99 self.hwindow = html.HtmlWindow(panel, -1,style=wx.BORDER,size=(700,500)) 92 100 # set the html page with the report string 93 self.hwindow.SetPage(self.report_ string)101 self.hwindow.SetPage(self.report_html) 94 102 # add panels to boxsizers 95 hbox.Add(bpanel)96 vbox.Add(hbox, 40, wx.EXPAND)103 #hbox.Add(bpanel) 104 vbox.Add(hbox,30, wx.EXPAND) 97 105 vbox.Add(panel,500, wx.EXPAND) 98 106 … … 109 117 wildcard ='HTML files (*.html)|*.html|'+ 110 118 'Text files (*.txt)|*.txt', 119 #'PDF files (*.pdf)|*.pdf', 111 120 style = wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR) 112 121 dlg.SetFilterIndex(0) #Set .html files to be default … … 115 124 dlg.Destroy() 116 125 return 126 117 127 fName = dlg.GetPath() 118 fName = os.path.splitext(fName)[0] + '.html' 119 dlg.Destroy() 120 121 html = self.report_string 122 f = open(fName, 'w') 123 f.write(html) 124 f.close() 125 126 128 129 if dlg.GetFilterIndex()== 0: 130 fName = os.path.splitext(fName)[0] + '.html' 131 dlg.Destroy() 132 133 #pic (png) file path/name 134 pic_fname = os.path.splitext(fName)[0] + '_img.png' 135 #put the path in html string 136 html = self.report_list[0] % pic_fname 137 f = open(fName, 'w') 138 f.write(html) 139 f.close() 140 #save png file using pic_fname 141 self.report_list[2].save(pic_fname) 142 elif dlg.GetFilterIndex()== 1: 143 fName = os.path.splitext(fName)[0] + '.txt' 144 dlg.Destroy() 145 146 text = self.report_list[1] 147 f = open(fName, 'w') 148 f.write(text) 149 f.close() 150 151 else: 152 dlg.Destroy() 153 127 154 def onPreview(self,event=None): 128 155 """ … … 132 159 """ 133 160 previewh=html.HtmlEasyPrinting(name="Printing", parentWindow=self) 134 previewh.PreviewText(self.report_ string)161 previewh.PreviewText(self.report_html) 135 162 136 163 def onPrint(self,event=None): … … 141 168 """ 142 169 printh=html.HtmlEasyPrinting(name="Printing", parentWindow=self) 143 printh.PrintText(self.report_ string)170 printh.PrintText(self.report_html) 144 171 172 173 def OnClose(self,event=None): 174 """ 175 Close the Dialog 145 176 177 : event: Close button event 178 """ 146 179 180 self.Close() 181 182
Note: See TracChangeset
for help on using the changeset viewer.