Changeset 6482


Ignore:
Timestamp:
Mar 10, 2009, 2:23:46 PM (15 years ago)
Author:
rwilson
Message:

Removed problem with tkinter error-handling after wxPython starts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • misc/tools/plotcsv/plotcsv.py

    r6480 r6482  
    159159    "zNHrrf9oCIxPMrO3N4LXSYQhEMeNpmcCKVywaA43JUYjwPeBTqcx3BIIOYTHHi74YjP4F4OI"
    160160    "IIgI9JOI2kS0JKI/m33TfzU+ASG0bvT61fpzAAAAAElFTkSuQmCC")
    161 
    162 
    163 def error(msg):
    164     print msg
    165     import tkinter_error
    166     tkinter_error.tkinter_error(msg)
    167     sys.exit(10)
    168161
    169162
     
    290283        x_index = header.index(x_hdr)
    291284    except ValueError:
    292         error("Sorry, X column header '%s' isn't in data file '%s'."
    293               % (x_hdr, filename))
     285        TheFrame.error("Sorry, X column header '%s' isn't in data file '%s'."
     286                     % (x_hdr, filename))
     287        return None
    294288
    295289    try:
    296290        y_index = header.index(y_hdr)
    297291    except ValueError:
    298         error("Sorry, Y column header '%s' isn't in data file '%s'."
    299               % (y_hdr, filename))
     292        TheFrame.error("Sorry, Y column header '%s' isn't in data file '%s'."
     293                       % (y_hdr, filename))
     294        return None
    300295
    301296    # get appropriate columns from data[]
     
    324319
    325320    for f in filenames:
    326         (x_data, y_data) = getCSVData(f, x_hdr, y_hdr)
     321        result = getCSVData(f, x_hdr, y_hdr)
     322        if result is None:          # some sort of error
     323            pylab.close()
     324            return
     325
     326        (x_data, y_data) = result
    327327        pylab.plot(x_data, y_data)
    328328
     
    354354        # Make the frame
    355355        wx.Frame.__init__(self, parent, id, title, pos=(50, 50),
    356                             size=(FORM_WIDTH, FORM_HEIGHT),
    357                             style=(wx.DEFAULT_FRAME_STYLE &
    358                                    ~ (wx.RESIZE_BOX | wx.MAXIMIZE_BOX |
    359                                       wx.RESIZE_BORDER)))
     356                          size=(FORM_WIDTH, FORM_HEIGHT),
     357                          style=(wx.DEFAULT_FRAME_STYLE &
     358                                 ~ (wx.RESIZE_BOX | wx.MAXIMIZE_BOX |
     359                                    wx.RESIZE_BORDER)))
    360360
    361361        p = self.panel = wx.Panel(self, -1)
     
    629629        '''Issue xwPython error message.'''
    630630       
    631         dlg = wx.MessageDialog(self, msg, 'Error',
    632                                wx.OK | wx.ICON_INFORMATION)
    633         dlg.ShowModal()
    634         dlg.Destroy()
     631        wx.MessageBox(msg, 'Error')
    635632
    636633       
     
    640637
    641638if __name__ == '__main__':
     639    global TheFrame
     640
     641    # The frame reference
     642    TheFrame = None
     643
    642644    app = wx.App()
    643     frame = MyFrame(None, -1, '%s %s' % (APP_NAME, APP_VERSION),
    644                     size=(FORM_WIDTH, FORM_HEIGHT))
    645     app.SetTopWindow(frame)
     645    TheFrame = MyFrame(None, -1, '%s %s' % (APP_NAME, APP_VERSION),
     646                       size=(FORM_WIDTH, FORM_HEIGHT))
     647    app.SetTopWindow(TheFrame)
    646648    app.MainLoop()
    647649
Note: See TracChangeset for help on using the changeset viewer.