Пример #1
0
 def CheckIndentation(self, doc, oof):
     #Indentation
     if config.prefs.docusefileindentation:
         indentation = doc.CheckIndentation(oof)
         if config.prefs.checkindentation:
             if config.prefs.docusetabs[doc.filetype]:
                 i = 1
             else:
                 i = -1
             if (indentation != i) and (indentation != 2):
                 answer = utils.Ask((doc.filename + ' is currently '\
                     + self.TABMESSAGE[indentation+1] +
                     ".\nWould you like to change it to the default?\nThe Default is: " +
                     self.TABMESSAGE[i+1]), "Indentation Not Default")
                 if answer:
                     indentation = i
                     if i == 1:
                         doc.SetToTabs(
                             config.prefs.doctabwidth[doc.filetype])
                     else:
                         doc.SetToSpaces(
                             config.prefs.doctabwidth[doc.filetype])
         if indentation == -1:
             usetabs = False
         elif indentation == 1:
             usetabs = True
         else:
             usetabs = config.prefs.docusetabs[doc.filetype]
         doc.SetUseTabs(usetabs)
         doc.SetupTabs(usetabs)
Пример #2
0
    def OnCloseFile(self, event):
        if not self.docMgr.currDoc:
            return

        if self.docMgr.currDoc.GetModify():
            if utils.Ask(u'你需要保存"%s"吗?' % self.docMgr.currDoc.GetFileName(),
                         "EasyPython"):
                self.OnSaveFile(event)

        self.docMgr.CloseDoc()
Пример #3
0
    def OnImportPrefs(self, event):
        if utils.Ask('This will permanently overwrite all of your preferences.\n\nProceed?', 'Warning'):
            dlg = drFileDialog.FileDialog(self.drframe, "Import Preferences From", 'Zip File (*.zip)|*.zip')

            if dlg.ShowModal() == wx.ID_OK:
                filename = dlg.GetPath().replace("\\", "/")
                drZip.ImportJustPreferencesFrom(self.drframe.AppDataDir, filename)
                self.drframe.ShowMessage('Successfully imported preferences.', 'Import Success')

            dlg.Destroy()
Пример #4
0
 def UpdateDocs(self):
     for doc in self.docs:
         if not doc.filename:
             continue
         if not os.path.exists(doc.filename):
             #TODO:文件删除处理
             continue
         current_mtime = int(os.stat(doc.filename).st_mtime)
         if current_mtime != doc.mtime:
             if utils.Ask(u'文件"%s"已经被修改了.要重新载入吗?' % (doc.filename),
                          "Reload File?"):
                 self.OpenFile(doc.filename, doc)
             doc.mtime = current_mtime
Пример #5
0
    def OnRun(self, event):
        if self.docMgr.selection < 0:
            return
        #patch [ 1367222 ] Improved Run Command + HTML Browser
        if self.docMgr.currDoc.GetModify():
            if not utils.Ask(u"文件已经被修改了,必须保存后才能运行.\n你需要保存文件吗?", "EasyPython"):
                return
            if not self.OnSaveFile(event):
                return

        if not utils.IsPythonFile(self.docMgr.currDoc.filename):
            return

        cwd = os.getcwd()

        cdir, filen = os.path.split(self.docMgr.currDoc.filename)
        try:
            os.chdir(cdir)
        except:
            utils.ShowMessage(u"不能转换当前工作目录到:%s." % cdir, u"EasyPython运行错误")
            return

        largs = ""
        if (len(EpyGlob.LastProgArgs) > 0):
            largs = ' ' + EpyGlob.LastProgArgs

        if config.PLATFORM_IS_WIN:
            self.RunCmd(("cmd /k " + config.pythexecw + ' "' +
                         self.docMgr.currDoc.filename.replace("\\", "/") +
                         '"' + largs), "Running " + filen, filen)
        else:
            self.RunCmd(
                (config.pythexec + " -u " + config.prefs.pythonargs + ' "' +
                 self.docMgr.currDoc.filename + '"' + largs),
                "Running " + filen, filen
            )  #patch: [ 1366679 ] Goto Line Should Not Display At Top Of Window
        os.chdir(cwd)