Changeset c0a30a24 in sasview for fittingview/src/sans


Ignore:
Timestamp:
Aug 11, 2011 8:20:32 AM (13 years ago)
Author:
Gervaise Alina <gervyh@…>
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:
1534c1d
Parents:
bcfc969
Message:

make sure media folder is found

Location:
fittingview/src/sans/perspectives/fitting
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fittingview/src/sans/perspectives/fitting/__init__.py

    r49c69de rc0a30a24  
    11PLUGIN_ID = "Fitting plug-in 1.0" 
    22from fitting import * 
     3 
     4import os 
     5def get_data_path(media): 
     6    """ 
     7    """ 
     8    # Check for data path in the package 
     9    path = os.path.join(os.path.dirname(__file__), media) 
     10    if os.path.isdir(path): 
     11        return path 
     12 
     13    # Check for data path next to exe/zip file. 
     14    # If we are inside a py2exe zip file, we need to go up 
     15    # to get to the directory containing  
     16    # the media for this module 
     17    path = os.path.dirname(__file__) 
     18    #Look for maximum n_dir up of the current dir to find media 
     19    n_dir = 12 
     20    for i in range(n_dir): 
     21        path, _ = os.path.split(path) 
     22        media_path = os.path.join(path, media) 
     23        if os.path.isdir(media_path): 
     24            module_media_path = os.path.join(media_path, 'fitting_media') 
     25            if os.path.isdir(module_media_path): 
     26                return module_media_path 
     27            return media_path 
     28    
     29    raise RuntimeError('Could not find models media files') 
     30 
     31def data_files(): 
     32    """ 
     33    Return the data files associated with media. 
     34     
     35    The format is a list of (directory, [files...]) pairs which can be 
     36    used directly in setup(...,data_files=...) for setup.py. 
     37 
     38    """ 
     39    data_files = [] 
     40    path = get_data_path(media="media") 
     41    for f in findall(path): 
     42        data_files.append(('media/fitting_media', [f])) 
     43    return data_files 
  • fittingview/src/sans/perspectives/fitting/help_panel.py

    r49c69de rc0a30a24  
    5555        self.path_pd = os.path.join(path,"pd_help.html") 
    5656        self.path_sm = os.path.join(path,"smear_computation.html") 
     57        import sans.perspectives.fitting as fitting 
     58         
     59        fitting_path = fitting.get_data_path(media='media') 
     60         
     61        _html_file = {"status_bar_help.html":"Status Bar Help", 
     62                      "load_data_help.html":"Load a File", 
     63                      "simultaneous_fit_help.html":"Simultaneous Fit", 
     64                      "single_fit_help.html":"Single Fit", 
     65                      "model_use_help.html":"Model Selection", 
     66                      "key_help.html":"Key Combination", 
     67                      } 
     68 
    5769                     
    5870        page1="""<html> 
     
    6476            <body> 
    6577            <ul> 
    66             <li><a href ="media/status_bar_help.html" target ="showframe">Status Bar Help</a><br></li> 
    67             <li><a href ="media/load_data_help.html" target ="showframe">Load a File</a><br></li> 
    68             <li><a href ="media/simultaneous_fit_help.html" target ="showframe">Simultaneous Fit</a><br></li> 
    69             <li><a href ="media/single_fit_help.html" target ="showframe">Single Fit</a><br></li> 
    70             <li><a href ="media/model_use_help.html" target ="showframe">Model Selection</a><br></li> 
    71             <li><a href ="%s" target ="showframe">Model Functions</a><br></li> 
    72             <li><a href ="%s" target ="showframe">Polydispersion Distributions</a><br></li> 
    73             <li><a href ="%s" target ="showframe">Smear Computation</a><br></li> 
    74             <li><a href ="media/key_help.html" target ="showframe">Key Combination</a><br></li> 
     78            """ 
     79        for p, title in _html_file.iteritems(): 
     80            pp = os.path.join(fitting_path, p) 
     81            page += """<li><a href ="%s" target="showframe">%s</a><br></li>""" % (pp, title) 
     82           
     83        page += """ 
     84            <li><a href ="%s" target="showframe">Model Functions</a><br></li> 
     85            <li><a href ="%s" target="showframe">Polydispersion Distributions</a><br></li> 
     86            <li><a href ="%s" target="showframe">Smear Computation</a><br></li> 
    7587            </ul> 
    7688            </body> 
     
    113125        link= event.GetLinkInfo().GetHref() 
    114126         
    115         self.rhelp.LoadPage(link) 
     127        self.rhelp.LoadPage(os.path.abspath(link)) 
    116128         
    117129""" 
Note: See TracChangeset for help on using the changeset viewer.