1
-
2
1
# Emoji Dictionary
3
2
4
3
# -----------------------------------------------------------------------------------------------------
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
7
6
import tkinter .messagebox as mbox
8
7
import tkinter as tk # imported tkinter as tk
9
8
import emoji
10
9
11
10
# -----------------------------------------------------------------------------------------------
12
11
12
+
13
13
class Keypad (tk .Frame ):
14
14
15
15
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
+ ],
20
86
]
21
87
22
88
def __init__ (self , * args , ** kwargs ):
23
89
super ().__init__ (* args , ** kwargs )
24
90
25
91
self .target = None
26
- self .memory = ''
92
+ self .memory = ""
27
93
28
94
for y , row in enumerate (self .cells ):
29
95
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" )
48
167
49
168
def get (self ):
50
169
if self .target :
51
170
return self .target .get ()
52
171
53
172
def append (self , text ):
54
173
if self .target :
55
- self .target .insert (' end' , text )
174
+ self .target .insert (" end" , text )
56
175
57
176
def clear (self ):
58
177
if self .target :
@@ -72,29 +191,29 @@ def space(self):
72
191
self .clear ()
73
192
self .append (text )
74
193
75
- def tab (self ): # 5 spaces
194
+ def tab (self ): # 5 spaces
76
195
if self .target :
77
196
text = self .get ()
78
197
text = text + " "
79
198
self .clear ()
80
199
self .append (text )
81
200
82
201
def copy (self ):
83
- #TODO: copy to clipboad
202
+ # TODO: copy to clipboad
84
203
if self .target :
85
204
self .memory = self .get ()
86
- self .label [' text' ] = ' memory: ' + self .memory
205
+ self .label [" text" ] = " memory: " + self .memory
87
206
print (self .memory )
88
207
89
208
def paste (self ):
90
- #TODO: copy from clipboad
209
+ # TODO: copy from clipboad
91
210
if self .target :
92
211
self .append (self .memory )
93
212
94
213
def show (self , entry ):
95
214
self .target = entry
96
215
97
- self .place (relx = 0.5 , rely = 0.6 , anchor = 'c' )
216
+ self .place (relx = 0.5 , rely = 0.6 , anchor = "c" )
98
217
99
218
def hide (self ):
100
219
self .target = None
@@ -105,71 +224,127 @@ def hide(self):
105
224
# function defined th=o clear both the input text and output text --------------------------------------------------
106
225
def clear_text ():
107
226
inputentry .delete (0 , END )
108
- outputtxt .delete ("1.0" ,"end" )
227
+ outputtxt .delete ("1.0" , "end" )
228
+
109
229
110
230
# function to search emoji
111
231
def search_emoji ():
112
232
word = inputentry .get ()
113
- if ( word == "" ) :
233
+ if word == "" :
114
234
outputtxt .insert (END , "You have entered no emoji." )
115
235
else :
116
236
means = emoji .demojize (word )
117
237
outputtxt .insert (END , "Meaning of Emoji : " + str (word ) + "\n \n " + means )
118
238
239
+
119
240
# main window created
120
241
window = tk .Tk ()
121
- window .title ("Emoji Dictionary" )
122
- window .geometry (' 1000x700' )
242
+ window .title ("Emoji Dictionary" )
243
+ window .geometry (" 1000x700" )
123
244
124
245
# 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 )
127
250
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 )
130
255
131
256
myname = StringVar (window )
132
257
firstclick1 = True
258
+
259
+
133
260
def on_inputentry_click (event ):
134
261
"""function that gets called whenever entry1 is clicked"""
135
262
global firstclick1
136
263
137
- if firstclick1 : # if this is the first time they clicked it
264
+ if firstclick1 : # if this is the first time they clicked it
138
265
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
140
267
141
268
142
269
# Taking input from TextArea
143
270
# 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
+ )
145
274
inputentry .place (x = 120 , y = 180 )
146
275
147
276
# # 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 )
149
287
150
288
# # 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 )
152
299
153
300
# 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 )
156
303
157
304
# # 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 )
160
316
161
317
# function for exiting
162
318
def exit_win ():
163
319
if mbox .askokcancel ("Exit" , "Do you want to exit?" ):
164
320
window .destroy ()
165
321
322
+
166
323
# # 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 )
168
334
169
335
keypad = Keypad (window )
170
336
171
337
# # 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 )
173
348
174
349
window .protocol ("WM_DELETE_WINDOW" , exit_win )
175
350
window .mainloop ()
0 commit comments