<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def onCancelButton(self, event):
 """ Quit grid with warning if unsaved changes present """

        if self.grid.changes:
            dlg1 = wx.MessageDialog(self, caption="Message:",
                                    message="Are you sure you want to exit this grid?\nYour changes will not be saved.\n ",
                                    style=wx.OK|wx.CANCEL)
            result = dlg1.ShowModal()
            if result == wx.ID_OK:
                dlg1.Destroy()
                self.Destroy()
        else:
            self.Destroy()
        if self.main_frame:
            self.main_frame.Show()
            self.main_frame.Raise()