Changeset dec793e in sasview for invariantview


Ignore:
Timestamp:
Apr 5, 2011 7:32:45 PM (13 years ago)
Author:
Jae Cho <jhjcho@…>
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
Message:

fixed the html report doc

Location:
invariantview
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • invariantview/media/report_template.html

    rb281210 rdec793e  
    4343 <tr> 
    4444  <td width=170 valign=top > 
    45   <p class=MsoNormal > porod  constant</p> 
     45  <p class=MsoNormal > porod constant</p> 
    4646  </td> 
    4747  <td width=213 valign=top > 
  • invariantview/perspectives/invariant/report_dialog.py

    rcf9b6950 rdec793e  
    2424    PANEL_HEIGHT = 700 
    2525    FONT_VARIANT = 0 
     26    ISMAC = False 
    2627else: 
    2728    _STATICBOX_WIDTH = 480 
     
    2930    PANEL_HEIGHT = 700 
    3031    FONT_VARIANT = 1 
    31      
    32  
    33          
     32    ISMAC = True 
     33   
    3434class ReportDialog(wx.Dialog): 
    3535    """ 
     
    5353        # font size  
    5454        self.SetWindowVariant(variant=FONT_VARIANT) 
     55 
     56        # check if tit is MAC 
     57        self.is_mac = ISMAC 
     58         
    5559        # report string 
    5660        self.report_list = list 
     
    5963        # layout 
    6064        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         
    6175         
    6276    def _setup_layout(self): 
     
    109123        self.Centre() 
    110124        self.Show(True) 
    111  
     125                 
    112126 
    113127    def onSave(self, event=None): 
     
    117131        #todo: complete saving fig file and as a txt file 
    118132        dlg = wx.FileDialog(self, "Choose a file", 
    119                             wildcard='HTML files (*.html)|*.html|'+ 
    120                             'Text files (*.txt)|*.txt', 
     133                            wildcard=self.wild_card, 
    121134                            style=wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR) 
    122135        dlg.SetFilterIndex(0) #Set .html files to be default 
     
    125138            dlg.Destroy() 
    126139            return 
    127          
     140 
    128141        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  
    131148        #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): 
    133177            ext = '.html' 
    134178            img_ext = '_img4html.png' 
    135179            report_frame = self.report_list[0] 
    136         elif ext_num == 1: 
     180        elif ext_num == (2 - ind_cor): 
    137181            ext = '.txt'    
    138182            # changing the image extension actually changes the image 
     
    142186        else: 
    143187            return 
    144          
     188 
    145189        #file name      
    146190        fName = os.path.splitext(fName)[0] + ext 
     
    149193        pic_fname = os.path.splitext(fName)[0] + img_ext 
    150194        #put the image path in html string 
    151         if ext_num == 0: 
     195        if ext_num == (1 - ind_cor): 
    152196            report = report_frame % pic_fname 
     197 
    153198        f = open(fName, 'w') 
    154199        f.write(report) 
Note: See TracChangeset for help on using the changeset viewer.