1-
21# Emoji Dictionary
32
43# -----------------------------------------------------------------------------------------------------
5- import io # used for dealing with input and output
6- from tkinter import * # importing the necessary libraries
4+ import io # used for dealing with input and output
5+ from tkinter import * # importing the necessary libraries
76import tkinter .messagebox as mbox
87import tkinter as tk # imported tkinter as tk
98import emoji
109
1110# -----------------------------------------------------------------------------------------------
1211
12+
1313class Keypad (tk .Frame ):
1414
1515 cells = [
16- ['😀' , '🥰' , '😴' , '🤓' , '🤮' , '🤬' , '😨' , '🤑' , '😫' , '😎' ],
17- ['🐒' ,'🐕' ,'🐎' ,'🐪' ,'🐁' ,'🐘' ,'🦘' ,'🦈' ,'🐓' ,'🐝' ,'👀' ,'🦴' ,'👩🏿' ,'🤝' ,'🧑' ,'🏾' ,'👱🏽' ,'♀' ,'🎞' ,'🎨' ,'⚽' ],
18- ['🍕' ,'🍗' ,'🍜' ,'☕' ,'🍴' ,'🍉' ,'🍓' ,'🌴' ,'🌵' ,'🛺' ,'🚲' ,'🛴' ,'🚉' ,'🚀' ,'✈' ,'🛰' ,'🚦' ,'🏳' ,'🌈' ,'🌎' ,'🧭' ],
19- ['🔥' ,'❄' ,'🌟' ,'🌞' ,'🌛' ,'🌝' ,'🌧' ,'🧺' ,'🧷' ,'🪒' ,'⛲' ,'🗼' ,'🕌' ,'👁' ,'🗨' ,'💬' ,'™' ,'💯' ,'🔕' ,'💥' ,'❤' ],
16+ ["😀" , "🥰" , "😴" , "🤓" , "🤮" , "🤬" , "😨" , "🤑" , "😫" , "😎" ],
17+ [
18+ "🐒" ,
19+ "🐕" ,
20+ "🐎" ,
21+ "🐪" ,
22+ "🐁" ,
23+ "🐘" ,
24+ "🦘" ,
25+ "🦈" ,
26+ "🐓" ,
27+ "🐝" ,
28+ "👀" ,
29+ "🦴" ,
30+ "👩🏿" ,
31+ "🤝" ,
32+ "🧑" ,
33+ "🏾" ,
34+ "👱🏽" ,
35+ "♀" ,
36+ "🎞" ,
37+ "🎨" ,
38+ "⚽" ,
39+ ],
40+ [
41+ "🍕" ,
42+ "🍗" ,
43+ "🍜" ,
44+ "☕" ,
45+ "🍴" ,
46+ "🍉" ,
47+ "🍓" ,
48+ "🌴" ,
49+ "🌵" ,
50+ "🛺" ,
51+ "🚲" ,
52+ "🛴" ,
53+ "🚉" ,
54+ "🚀" ,
55+ "✈" ,
56+ "🛰" ,
57+ "🚦" ,
58+ "🏳" ,
59+ "🌈" ,
60+ "🌎" ,
61+ "🧭" ,
62+ ],
63+ [
64+ "🔥" ,
65+ "❄" ,
66+ "🌟" ,
67+ "🌞" ,
68+ "🌛" ,
69+ "🌝" ,
70+ "🌧" ,
71+ "🧺" ,
72+ "🧷" ,
73+ "🪒" ,
74+ "⛲" ,
75+ "🗼" ,
76+ "🕌" ,
77+ "👁" ,
78+ "🗨" ,
79+ "💬" ,
80+ "™" ,
81+ "💯" ,
82+ "🔕" ,
83+ "💥" ,
84+ "❤" ,
85+ ],
2086 ]
2187
2288 def __init__ (self , * args , ** kwargs ):
2389 super ().__init__ (* args , ** kwargs )
2490
2591 self .target = None
26- self .memory = ''
92+ self .memory = ""
2793
2894 for y , row in enumerate (self .cells ):
2995 for x , item in enumerate (row ):
30- b = tk .Button (self , text = item , command = lambda text = item :self .append (text ),font = ("Arial" , 14 ), bg = "yellow" , fg = "blue" , borderwidth = 3 , relief = "raised" )
31- b .grid (row = y , column = x , sticky = 'news' )
32-
33- x = tk .Button (self , text = 'Space' , command = self .space ,font = ("Arial" , 14 ), bg = "yellow" , fg = "blue" , borderwidth = 3 , relief = "raised" )
34- x .grid (row = 0 , column = 10 , columnspan = '2' , sticky = 'news' )
35-
36- x = tk .Button (self , text = 'tab' , command = self .tab ,font = ("Arial" , 14 ), bg = "yellow" , fg = "blue" , borderwidth = 3 , relief = "raised" )
37- x .grid (row = 0 , column = 12 , columnspan = '2' , sticky = 'news' )
38-
39- x = tk .Button (self , text = 'Backspace' , command = self .backspace ,font = ("Arial" , 14 ), bg = "yellow" , fg = "blue" , borderwidth = 3 , relief = "raised" )
40- x .grid (row = 0 , column = 14 ,columnspan = '3' , sticky = 'news' )
41-
42- x = tk .Button (self , text = 'Clear' , command = self .clear ,font = ("Arial" , 14 ), bg = "yellow" , fg = "blue" , borderwidth = 3 , relief = "raised" )
43- x .grid (row = 0 , column = 17 , columnspan = '2' , sticky = 'news' )
44-
45- x = tk .Button (self , text = 'Hide' , command = self .hide ,font = ("Arial" , 14 ), bg = "yellow" , fg = "blue" , borderwidth = 3 , relief = "raised" )
46- x .grid (row = 0 , column = 19 , columnspan = '2' , sticky = 'news' )
47-
96+ b = tk .Button (
97+ self ,
98+ text = item ,
99+ command = lambda text = item : self .append (text ),
100+ font = ("Arial" , 14 ),
101+ bg = "yellow" ,
102+ fg = "blue" ,
103+ borderwidth = 3 ,
104+ relief = "raised" ,
105+ )
106+ b .grid (row = y , column = x , sticky = "news" )
107+
108+ x = tk .Button (
109+ self ,
110+ text = "Space" ,
111+ command = self .space ,
112+ font = ("Arial" , 14 ),
113+ bg = "yellow" ,
114+ fg = "blue" ,
115+ borderwidth = 3 ,
116+ relief = "raised" ,
117+ )
118+ x .grid (row = 0 , column = 10 , columnspan = "2" , sticky = "news" )
119+
120+ x = tk .Button (
121+ self ,
122+ text = "tab" ,
123+ command = self .tab ,
124+ font = ("Arial" , 14 ),
125+ bg = "yellow" ,
126+ fg = "blue" ,
127+ borderwidth = 3 ,
128+ relief = "raised" ,
129+ )
130+ x .grid (row = 0 , column = 12 , columnspan = "2" , sticky = "news" )
131+
132+ x = tk .Button (
133+ self ,
134+ text = "Backspace" ,
135+ command = self .backspace ,
136+ font = ("Arial" , 14 ),
137+ bg = "yellow" ,
138+ fg = "blue" ,
139+ borderwidth = 3 ,
140+ relief = "raised" ,
141+ )
142+ x .grid (row = 0 , column = 14 , columnspan = "3" , sticky = "news" )
143+
144+ x = tk .Button (
145+ self ,
146+ text = "Clear" ,
147+ command = self .clear ,
148+ font = ("Arial" , 14 ),
149+ bg = "yellow" ,
150+ fg = "blue" ,
151+ borderwidth = 3 ,
152+ relief = "raised" ,
153+ )
154+ x .grid (row = 0 , column = 17 , columnspan = "2" , sticky = "news" )
155+
156+ x = tk .Button (
157+ self ,
158+ text = "Hide" ,
159+ command = self .hide ,
160+ font = ("Arial" , 14 ),
161+ bg = "yellow" ,
162+ fg = "blue" ,
163+ borderwidth = 3 ,
164+ relief = "raised" ,
165+ )
166+ x .grid (row = 0 , column = 19 , columnspan = "2" , sticky = "news" )
48167
49168 def get (self ):
50169 if self .target :
51170 return self .target .get ()
52171
53172 def append (self , text ):
54173 if self .target :
55- self .target .insert (' end' , text )
174+ self .target .insert (" end" , text )
56175
57176 def clear (self ):
58177 if self .target :
@@ -72,29 +191,29 @@ def space(self):
72191 self .clear ()
73192 self .append (text )
74193
75- def tab (self ): # 5 spaces
194+ def tab (self ): # 5 spaces
76195 if self .target :
77196 text = self .get ()
78197 text = text + " "
79198 self .clear ()
80199 self .append (text )
81200
82201 def copy (self ):
83- #TODO: copy to clipboad
202+ # TODO: copy to clipboad
84203 if self .target :
85204 self .memory = self .get ()
86- self .label [' text' ] = ' memory: ' + self .memory
205+ self .label [" text" ] = " memory: " + self .memory
87206 print (self .memory )
88207
89208 def paste (self ):
90- #TODO: copy from clipboad
209+ # TODO: copy from clipboad
91210 if self .target :
92211 self .append (self .memory )
93212
94213 def show (self , entry ):
95214 self .target = entry
96215
97- self .place (relx = 0.5 , rely = 0.6 , anchor = 'c' )
216+ self .place (relx = 0.5 , rely = 0.6 , anchor = "c" )
98217
99218 def hide (self ):
100219 self .target = None
@@ -105,71 +224,127 @@ def hide(self):
105224# function defined th=o clear both the input text and output text --------------------------------------------------
106225def clear_text ():
107226 inputentry .delete (0 , END )
108- outputtxt .delete ("1.0" ,"end" )
227+ outputtxt .delete ("1.0" , "end" )
228+
109229
110230# function to search emoji
111231def search_emoji ():
112232 word = inputentry .get ()
113- if ( word == "" ) :
233+ if word == "" :
114234 outputtxt .insert (END , "You have entered no emoji." )
115235 else :
116236 means = emoji .demojize (word )
117237 outputtxt .insert (END , "Meaning of Emoji : " + str (word ) + "\n \n " + means )
118238
239+
119240# main window created
120241window = tk .Tk ()
121- window .title ("Emoji Dictionary" )
122- window .geometry (' 1000x700' )
242+ window .title ("Emoji Dictionary" )
243+ window .geometry (" 1000x700" )
123244
124245# for writing Dictionary label, at the top of window
125- dic = tk .Label (text = "EMOJI DICTIONARY" , font = ("Arial" , 50 ,"underline" ), fg = "magenta" ) # same way bg
126- dic .place (x = 160 , y = 10 )
246+ dic = tk .Label (
247+ text = "EMOJI DICTIONARY" , font = ("Arial" , 50 , "underline" ), fg = "magenta"
248+ ) # same way bg
249+ dic .place (x = 160 , y = 10 )
127250
128- start1 = tk .Label (text = "Enter any Emoji you want to search..." , font = ("Arial" , 30 ), fg = "green" ) # same way bg
129- start1 .place (x = 160 , y = 120 )
251+ start1 = tk .Label (
252+ text = "Enter any Emoji you want to search..." , font = ("Arial" , 30 ), fg = "green"
253+ ) # same way bg
254+ start1 .place (x = 160 , y = 120 )
130255
131256myname = StringVar (window )
132257firstclick1 = True
258+
259+
133260def on_inputentry_click (event ):
134261 """function that gets called whenever entry1 is clicked"""
135262 global firstclick1
136263
137- if firstclick1 : # if this is the first time they clicked it
264+ if firstclick1 : # if this is the first time they clicked it
138265 firstclick1 = False
139- inputentry .delete (0 , "end" ) # delete all the text in the entry
266+ inputentry .delete (0 , "end" ) # delete all the text in the entry
140267
141268
142269# Taking input from TextArea
143270# inputentry = Entry(window,font=("Arial", 35), width=33, border=2)
144- inputentry = Entry (window ,font = ("Arial" , 35 ) , width = 28 , border = 2 , bg = "light yellow" , fg = "brown" )
271+ inputentry = Entry (
272+ window , font = ("Arial" , 35 ), width = 28 , border = 2 , bg = "light yellow" , fg = "brown"
273+ )
145274inputentry .place (x = 120 , y = 180 )
146275
147276# # Creating Search Button
148- Button (window ,text = "🔍 SEARCH" ,command = search_emoji ,font = ("Arial" , 20 ), bg = "light green" , fg = "blue" , borderwidth = 3 , relief = "raised" ).place (x = 270 , y = 250 )
277+ Button (
278+ window ,
279+ text = "🔍 SEARCH" ,
280+ command = search_emoji ,
281+ font = ("Arial" , 20 ),
282+ bg = "light green" ,
283+ fg = "blue" ,
284+ borderwidth = 3 ,
285+ relief = "raised" ,
286+ ).place (x = 270 , y = 250 )
149287
150288# # creating clear button
151- Button (window ,text = "🧹 CLEAR" ,command = clear_text ,font = ("Arial" , 20 ), bg = "orange" , fg = "blue" , borderwidth = 3 , relief = "raised" ).place (x = 545 , y = 250 )
289+ Button (
290+ window ,
291+ text = "🧹 CLEAR" ,
292+ command = clear_text ,
293+ font = ("Arial" , 20 ),
294+ bg = "orange" ,
295+ fg = "blue" ,
296+ borderwidth = 3 ,
297+ relief = "raised" ,
298+ ).place (x = 545 , y = 250 )
152299
153300# meaning label
154- start1 = tk .Label (text = "Meaning..." , font = ("Arial" , 30 ), fg = "green" ) # same way bg
155- start1 .place (x = 160 , y = 340 )
301+ start1 = tk .Label (text = "Meaning..." , font = ("Arial" , 30 ), fg = "green" ) # same way bg
302+ start1 .place (x = 160 , y = 340 )
156303
157304# # Output TextBox Creation
158- outputtxt = tk .Text (window ,height = 7 , width = 57 , font = ("Arial" , 17 ), bg = "light yellow" , fg = "brown" , borderwidth = 3 , relief = "solid" )
159- outputtxt .place (x = 120 , y = 400 )
305+ outputtxt = tk .Text (
306+ window ,
307+ height = 7 ,
308+ width = 57 ,
309+ font = ("Arial" , 17 ),
310+ bg = "light yellow" ,
311+ fg = "brown" ,
312+ borderwidth = 3 ,
313+ relief = "solid" ,
314+ )
315+ outputtxt .place (x = 120 , y = 400 )
160316
161317# function for exiting
162318def exit_win ():
163319 if mbox .askokcancel ("Exit" , "Do you want to exit?" ):
164320 window .destroy ()
165321
322+
166323# # creating exit button
167- Button (window ,text = "❌ EXIT" ,command = exit_win ,font = ("Arial" , 20 ), bg = "red" , fg = "black" , borderwidth = 3 , relief = "raised" ).place (x = 435 , y = 610 )
324+ Button (
325+ window ,
326+ text = "❌ EXIT" ,
327+ command = exit_win ,
328+ font = ("Arial" , 20 ),
329+ bg = "red" ,
330+ fg = "black" ,
331+ borderwidth = 3 ,
332+ relief = "raised" ,
333+ ).place (x = 435 , y = 610 )
168334
169335keypad = Keypad (window )
170336
171337# # creating speech to text button
172- v_keypadb = Button (window ,text = "⌨" ,command = lambda :keypad .show (inputentry ),font = ("Arial" , 18 ), bg = "light yellow" , fg = "green" , borderwidth = 3 , relief = "raised" ).place (x = 870 , y = 183 )
338+ v_keypadb = Button (
339+ window ,
340+ text = "⌨" ,
341+ command = lambda : keypad .show (inputentry ),
342+ font = ("Arial" , 18 ),
343+ bg = "light yellow" ,
344+ fg = "green" ,
345+ borderwidth = 3 ,
346+ relief = "raised" ,
347+ ).place (x = 870 , y = 183 )
173348
174349window .protocol ("WM_DELETE_WINDOW" , exit_win )
175350window .mainloop ()
0 commit comments