1
+ from tkinter import *
2
+ from tkinter import ttk
3
+ from tkinter import messagebox
4
+ from PyDictionary import PyDictionary
5
+ from englisttohindi .englisttohindi import EngtoHindi
6
+
7
+
8
+ def get_meaning ():
9
+ dictionary = PyDictionary ()
10
+ get_word = txt_input .get ()
11
+ format = language_format .get ()
12
+ if get_word == "" :
13
+ messagebox .showerror ('Dictionary' , 'Please enter the word' )
14
+ elif format == 'English-to-English' :
15
+ outputbox .delete ("1.0" , "end" )
16
+ d = dictionary .meaning (get_word )
17
+ outputbox .insert ('end' , d ['Noun' ])
18
+ elif format == 'English-to-Hindi' :
19
+ d = dictionary .meaning (get_word )
20
+ res = EngtoHindi (d ['Noun' ]).convert
21
+ outputbox .delete ("1.0" , "end" )
22
+ outputbox .insert ('end' , res )
23
+
24
+
25
+ # Driver Code
26
+ if __name__ == "__main__" :
27
+ # Create root window
28
+ root = Tk ()
29
+ # Change the title
30
+ root .title ('Dictionary' )
31
+ # Change the window size
32
+ root .geometry ('300x400' )
33
+ # no resize for both directions
34
+ root .resizable (False , False )
35
+
36
+ # set gui widgets
37
+ lbl_format = Label (root , text = "Select Format :" ,
38
+ font = ("Times New Roman" , 12 ))
39
+ lbl_word = Label (root , text = "Enter Word :" ,
40
+ font = ("Times New Roman" , 12 ))
41
+ txt_input = Entry (root , width = 20 , bd = "2" , font = "18" , relief = RIDGE )
42
+ btn_get_meaning = Button (root , text = 'Search' , width = 6 ,
43
+ command = get_meaning , font = ("Times New Roman" , 14 ), relief = RIDGE )
44
+ lbl_means = Label (root , text = "Meaning :" ,
45
+ font = ("verdana" , 14 , 'bold' ))
46
+ outputbox = Text (root , width = 29 , height = 11 ,
47
+ relief = RIDGE , bd = "2" , pady = 5 , padx = 3 , spacing2 = 3 , font = ("Times New Roman" , 13 ))
48
+
49
+ # Place Geometry
50
+ lbl_format .place (x = 10 , y = 13 )
51
+ lbl_word .place (x = 10 , y = 60 )
52
+ txt_input .place (x = 100 , y = 60 )
53
+ btn_get_meaning .place (x = 213 , y = 100 )
54
+ lbl_means .place (x = 10 , y = 130 )
55
+ outputbox .place (x = 12 , y = 165 )
56
+
57
+ # Combobox creation
58
+ n = StringVar ()
59
+ language_format = ttk .Combobox (root , width = 25 , textvariable = n ,)
60
+
61
+ # Adding combobox drop down list
62
+ language_format ['values' ] = ('English-to-English' ,
63
+ 'English-to-Hindi' )
64
+
65
+ language_format .place (x = 115 , y = 15 )
66
+ language_format .current (0 )
67
+
68
+ # start mainloop
69
+ root .mainloop ()
0 commit comments