import pn import scintilla from pypn.decorators import script import enchant import wx from enchant.checker import SpellChecker from enchant.checker.wxSpellCheckerDialog import wxSpellCheckerDialog @script("Spellcheck", "Text") def Spellcheck(): class SpellDialog(wxSpellCheckerDialog): def __init__(self,*args): wxSpellCheckerDialog.__init__(self,*args) wx.EVT_CLOSE(self,self.OnClose) def OnClose(self,evnt): if self._checker is not None: text = self._checker.get_text() editor.BeginUndoAction() editor.ClearAll() editor.AddText(len(text), text) editor.EndUndoAction() self.Destroy() editor = scintilla.Scintilla(pn.CurrentDoc()) text = editor.GetTextRange (0, editor.Length) #app = wx.App(0) ### PySimpleApp is deprecated,but works anyway app = wx.PySimpleApp() dlg = SpellDialog() chkr = SpellChecker("en_US",text) dlg.SetSpellChecker(chkr) dlg.Show() app.MainLoop()