In this video we’ll create a simple Spell Checker app with Kivy and Python!

We’ll use the built in Spelling module in Kivy and the PyEnchant Library for the actual spell checking!

We’ll create an app with a label, a textinput box, and a button. Users can enter a word and click the button and the app will check the word for spelling errors and return suggestions of correct spellings.

Python Code: spell.py
GitHub Code: spell.py

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty
from kivy.lang import Builder
from kivy.core.spelling import Spelling

# Designate Our .kv design file 
Builder.load_file('spell.kv')

class MyLayout(Widget):
	def press(self):
		# Create instance of Spelling
		s = Spelling()

		# Select the language
		s.select_language('en_US')

		# See the language options
		#print(s.list_languages())

		# Grab the word from the textbox
		word = self.ids.word_input.text

		options = s.suggest(word)
		x = ''
		for item in options:
			x = f'{x} {item}'
		# update our label
		self.ids.word_label.text = f'{x}'

		# Clear input box
		self.ids.word_input.text = ''


class AwesomeApp(App):
	def build(self):
		return MyLayout()

if __name__ == '__main__':
	AwesomeApp().run()




Kivy Design Code: spell.kv
GitHub Code: spell.kv

<MyLayout>
	BoxLayout:
		orientation: "vertical"
		size: root.width, root.height
	
		Label:
			id: word_label
			text_size: self.size
			halign: "center"
			valign: "middle"
			text: "Enter A Word"
			font_size:32


		TextInput:
			id: word_input
			multiline: False
			size_hint: (1, .5)

		Button:
			size_hint: (1, .5)
			font_size: 32
			text: "Submit"
			on_press: root.press()


John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of the first dot com boom. After that he developed the award-winning Submission-Spider search engine submission software that's been used by over 3 million individuals, businesses, and governments in over 42 countries. He's written several Amazon #1 best selling books on coding, and runs a popular Youtube coding channel.

View all posts

Add comment

Your email address will not be published. Required fields are marked *

John Elder