0

根据 pyenchant文档的用法如下,

>> 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()

这将打开拼写更正对话框。

那么我怎样才能得到修改后的文本呢?

编辑 1:

text = chkr.get_text() 返回更正的文本。但我收到以下错误。

PyAssertionError at /quiz/submit/ C++ 断言 "wxThread::IsMain()" failed at ....\src\msw\evtloop.cpp(244) in wxEventLoop::Dispatch(): 只有主线程可以处理 Windows 消息

这是我实现的代码

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()
4

1 回答 1

1

我很确定您调用chkr.getText()which 返回更正后的文本。

于 2012-05-07T04:49:59.140 回答