Decode the language of emojis into plain text using Python. In this tutorial, you will know the meaning of all the different emojis used in any text by using the Python Tkinter GUI. The demoji module in Python can be used to translate emoticons and emojis into text. Emojis in text strings can be precisely replaced and removed with this tool.
Please download the source code of Python Emoji to Text Converter Project from the following link: Python Emoji to Text Converter Project Code
Following are the steps for developing the Python Emoji to Text Converter Project:
To use Tkinter, we need to import the Tkinter module. We are also going to import the demoji module to get all kinds of emojis and download its codes.
Code
#import packages
from tkinter import *
import demoji
demoji.download_codes()
This code sets the title of the window as ‘ProjectGurukul Emoji to Text’, and sets the dimensions ‘width x length’.
Code
def emoji_to_text():
emoji = entry.get()
text1 = demoji.findall(emoji)
l3.configure(text=str(text1))
Explanation:
We use entry.get() to get the input emojis and demoji.findall to get the emoji’s description and l3.configure to display it by configuring the l3 label.
We make a label to give heading Emoji to Text Converter, a frame1 to get emojis as input from the user by creating an entry widget, and after that, we create a button widget and assign the emoji_to_text function to it. At the end, we create a label for the output, which we can configure to display the textual description of each emoji in the text format.
Code
frame = Frame(root)
frame.pack(pady=20)
label = Label(frame, text="Emoji to Text Converter",fg="blue",font=("Arial", 15,))
label.pack(side="left", padx=10)
# create input field for emoji
frame1 = Frame(root)
frame1.pack(pady=20)
l1 = Label(frame1, text="Enter Text:",bg="lightgreen",font=("Arial", 15))
l1.pack(side="left", padx=10)
entry = Entry(frame1, font=("Arial", 15), width=15)
entry.pack(side="left", pady=20)
# create button to convert emoji to text
button = Button(root, text="Convert", font=("Arial", 15),bg="lightgreen", command=emoji_to_text)
button.pack()
# create label to display the converted text
l2 = Label(root,text="Description:", font=("Arial", 15),bg="orange")
l2.pack(pady=20)
l3 = Label(root, font=("Arial", 15),bg="yellow")
l3.pack(pady=20)
# run the tkinter window
root.mainloop()
from tkinter import *
import demoji
demoji.download_codes()
def emoji_to_text():
emoji = entry.get()
text1 = demoji.findall(emoji)
l3.configure(text=str(text1))
# create a tkinter window
root = Tk()
root.geometry("400x400")
root.title("ProjectGurukul Emoji to Text")
frame = Frame(root)
frame.pack(pady=20)
label = Label(frame, text="Emoji to Text Converter",fg="blue",font=("Arial", 15,))
label.pack(side="left", padx=10)
# create input field for emoji
frame1 = Frame(root)
frame1.pack(pady=20)
l1 = Label(frame1, text="Enter Text:",bg="lightgreen",font=("Arial", 15))
l1.pack(side="left", padx=10)
entry = Entry(frame1, font=("Arial", 15), width=15)
entry.pack(side="left", pady=20)
# create button to convert emoji to text
button = Button(root, text="Convert", font=("Arial", 15),bg="lightgreen", command=emoji_to_text)
button.pack()
# create label to display the converted text
l2 = Label(root,text="Description:", font=("Arial", 15),bg="orange")
l2.pack(pady=20)
l3 = Label(root, font=("Arial", 15),bg="yellow")
l3.pack(pady=20)
# run the tkinter window
root.mainloop()
We can now easily know the meaning of all the different emojis used in any text by using the Python Tkinter GUI. This project provides practical exposure to various Python libraries, such as tkinter and the demoji module, and how to create a function and assign it to a button.
#python