"Spellchecking (myspell)" by avion
Rating:









(0 votes)
| Name: | Spellchecking (myspell) |
|---|---|
| Uploaded By: | avion |
| Date Created: | June 20, 2009 6:20 p.m. |
| Date Modified: | June 22, 2009 1:53 p.m. |
| Description: | Spellchecking with help of enchant and wx gui. You will need working python installation and enchant + wxgui modules. (later could be changed with simple modification to the code to support gtk/win32 or console) |
| Num Views: | 1480 |
| Num Downloads: | 367 |
Contents
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()
Links to needed Python modules:
* wxgui:
http://wxpython.org/download.php
* enchant:
http://pypi.python.org/pypi/pyenchant/1.6.3
You need to put language files in:
...\Python26\Lib\site-packages\enchant\share\enchant\myspell\
Posted by Nux on Sept. 29, 2010 at 5:27 p.m.