How to use wxSpellCheckerDialog in Django?

2019-09-07 02:59发布

问题:

According to pyenchant documentation usage is follows,

>> import wx
>> from enchant.checker import SpellChecker
>> from enchant.checker.wxSpellCheckerDialog import wxSpellCheckerDialog
>>
>> app = wx.PySimpleApp()
>> text = "This is sme text with a fw speling errors in it. Here are a fw more to tst it ut."
>> dlg = wxSpellCheckerDialog(None,-1,"")
>> chkr = SpellChecker("en_US",text)
>> dlg.SetSpellChecker(chkr)
>> dlg.Show()
>> app.MainLoop()

This opens spell correction dialogbox.

So how can i get modified text back ?

EDIT 1 :

text = chkr.get_text() returns corrected text. But I'm getting following error.

PyAssertionError at /quiz/submit/ C++ assertion "wxThread::IsMain()" failed at ....\src\msw\evtloop.cpp(244) in wxEventLoop::Dispatch(): only the main thread can process Windows messages

This is the code i implemented

app = wx.PySimpleApp()
text = "This is sme text with a fw speling errors in it. Here are a fw more to tst it ut."
dlg = wxSpellCheckerDialog(None,-1,"")
chkr = SpellChecker("en_US",text)
dlg.SetSpellChecker(chkr)
dlg.ShowModal()
text = chkr.get_text()

回答1:

I am pretty sure you call chkr.getText() which returns the corrected text.