Build a Quick Language Detection App – Python Tkinter GUI Tutorial 222

In this video we’ll build a cool Language Detection app with Tkinter and Python.

We’ll use the langdetect and the langcodes libraries for Python to do most of the heavy lifting.

We’ll use a Text box to get user input, and a button and label to round out the app.

Python Code: lang.py
(Github Code)

from tkinter import *
from langdetect import detect
from langcodes import *

root = Tk()
root.title('Codemy.com - Language Detection!')

root.geometry("500x350")

def check_lang():
	if my_text.compare("end-1c", "==", "1.0"):
		my_label.config(text="Hey! You forgot to enter anything...")
	else:
		code = detect(my_text.get(1.0, END))
		my_result = Language.make(language=code).display_name()
		my_label.config(text=f"Your Language Is: {my_result}")


my_text = Text(root, height=10, width=50)
my_text.pack(pady=20)

my_button = Button(root, text="Check Language", command=check_lang)
my_button.pack(pady=20)

my_label = Label(root, text="")
my_label.pack(pady=10)


root.mainloop()

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

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...