def AskToReload(self, cfile): """Show a dialog asking if the file should be reloaded @param win: Window to prompt dialog on top of @param cfile: the file to prompt for a reload of """ mdlg = wx.MessageDialog( self, _("%s has been modified by another " "application.\n\nWould you like " "to Reload it?") % cfile, _("Reload File?"), wx.YES_NO | wx.ICON_INFORMATION) mdlg.CenterOnParent() result = mdlg.ShowModal() mdlg.Destroy() if result == wx.ID_YES: ret, rmsg = self.ReloadFile() if not ret: errmap = dict(filename=cfile, errmsg=rmsg) mdlg = wx.MessageDialog( self, _("Failed to reload %(filename)s:\n" "Error: %(errmsg)s") % errmap, _("Error"), wx.OK | wx.ICON_ERROR) mdlg.ShowModal() mdlg.Destroy() else: self.SetModTime(GetFileModTime(cfile))
def DoOnIdle(self): """Check if the file has been modified and prompt a warning""" if Profile_Get('CHECKMOD'): cfile = self.GetFileName() lmod = GetFileModTime(cfile) if self.GetModTime() and not lmod and not os.path.exists(cfile): wx.CallAfter(self.PromptToReSave, cfile) elif self.GetModTime() < lmod: wx.CallAfter(self.AskToReload, cfile) else: pass
def DoOnIdle(self): """Check if the file has been modified and prompt a warning""" if Profile_Get('CHECKMOD'): cfile = self.GetFileName() lmod = GetFileModTime(cfile) mtime = self.GetModTime() if mtime and not lmod and not os.path.exists(cfile): wx.CallAfter(self.PromptToReSave, cfile) elif mtime < lmod: # Check if we should automatically reload the file or not if Profile_Get('AUTO_RELOAD', default=False) and \ not self.GetModify(): wx.CallAfter(self.DoReloadFile) else: wx.CallAfter(self.AskToReload, cfile) else: pass
def AskToReload(self, cfile): """Show a dialog asking if the file should be reloaded @param win: Window to prompt dialog on top of @param cfile: the file to prompt for a reload of """ mdlg = wx.MessageDialog(self, _("%s has been modified by another " "application.\n\nWould you like " "to reload it?") % cfile, _("Reload File?"), wx.YES_NO | wx.ICON_INFORMATION) mdlg.CenterOnParent() result = mdlg.ShowModal() mdlg.Destroy() if result == wx.ID_YES: self.DoReloadFile() else: self.SetModTime(GetFileModTime(cfile))