Changeset cb0d17c in sasview for guiframe


Ignore:
Timestamp:
Aug 1, 2009 8:20:08 AM (15 years ago)
Author:
Mathieu Doucet <doucetm@…>
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:
d7412e0
Parents:
e082e2c
Message:

guiframe: pop up error message when a file can't be loaded.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • guiframe/data_loader.py

    rd4ccbb1 rcb0d17c  
    7171    return None, None, None, None 
    7272 
     73def load_error(error=None): 
     74    """ 
     75        Pop up an error message. 
     76         
     77        @param error: details error message to be displayed 
     78    """ 
     79    message = "You had to try this, didn't you?\n\n" 
     80    message += "The data file you selected could not be loaded.\n" 
     81    message += "Make sure the content of your file is properly formatted.\n\n" 
     82     
     83    if error is not None: 
     84        message += "When contacting the DANSE team, mention the following:\n%s" % str(error) 
     85     
     86    dial = wx.MessageDialog(None, message, 'Error Loading File', wx.OK | wx.ICON_EXCLAMATION) 
     87    dial.ShowModal()     
     88 
    7389def plot_data(parent, path): 
    7490    """ 
     
    7995    from DataLoader.loader import  Loader 
    8096    
    81     #Instantiate a loader  
     97    # Instantiate a loader  
    8298    L = Loader() 
    8399     
    84     #Recieves data  
     100    # Load data  
    85101    try: 
    86102        output=L.load(path) 
    87         if output==None: 
    88             msg="Could not open this page" 
    89             wx.PostEvent(parent, StatusEvent(status=msg)) 
    90             return 
    91103    except: 
    92         wx.PostEvent(parent, StatusEvent(status="Problem loading file: %s" % sys.exc_value)) 
     104        load_error(sys.exc_value) 
    93105        return 
    94106     
     107    # Notify user if the loader completed the load but no data came out 
     108    if output == None: 
     109        load_error("The data file appears to be empty.") 
     110        return 
    95111   
    96112    filename = os.path.basename(path) 
Note: See TracChangeset for help on using the changeset viewer.