Using spelling
Depending on the kind of app that we will develop, we will need to spellcheck text provided by the user. In the Kivy API, there is a package to deal with it. In this recipe, we will give an example of how to do it.
Getting ready
If you are not using Mac OS X (or OS X as Apple called now), we will need to install the Python package: PyEnchant. For the installation, let's use the pip
tool as follows:
pip
install PyEnchant
How to do it…
Because this recipe could use it in different contexts, let's work directly in Python. We want to make some suggestions to the word misspelled. To complete the task, follow these steps:
Import the
Spelling
package.from kivy.core.spelling import Spelling
Instance the object s as
Spelling()
.s = Spelling()
List the available language.
s.list_languages()
In this case, select U.S. English.
s.select_language('en_US')
Ask for a suggestion to the object
s
.s.suggest('mispell')
How it works…
The first four steps actually set the kind of suggestion that we want...