How to use wxSpellCheckerDialog in Django?

眉间皱痕 提交于 2019-12-11 17:47:04

问题


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.



来源:https://stackoverflow.com/questions/10474971/how-to-use-wxspellcheckerdialog-in-django

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!