1
- import mysql . connector
1
+ # Including required modules
2
2
3
+ import mysql .connector
3
4
from tkinter import *
4
5
import speech_recognition as sr
5
6
import pyttsx3
6
7
8
+ # assigining the voice commands
7
9
engine = pyttsx3 .init ('sapi5' )
8
10
voices = engine .getProperty ('voices' )
9
11
# print(voices[1].id)
10
12
engine .setProperty ('voice' , voices [0 ].id )
11
13
12
-
14
+ # function to speak
13
15
def speak (audio ):
14
16
engine .say (audio )
15
17
engine .runAndWait ()
16
-
18
+ # making the connections towards the mysql
17
19
def connection ():
18
20
try :
19
21
con = mysql .connector .connect (user = 'root' ,password = '4844' ,host = '127.0.0.1' ,database = 'kbook' )
20
22
mycursor = con .cursor ()
23
+ #creating the servers
21
24
mycursor .execute ("CREATE TABLE IF NOT EXIST ITEMS (CID INT PRIMARY KEY,COUSTOMER_NAME VARCHAR(25),ITEM1 VARCHAR(20),WORTH1 INT,ITEM2 VARCHAR(20),WORTH2 INT,TOTAL_AMOUNT INT)" )
22
25
except :
23
26
print ("cannot Connect to database" )
24
27
return con
25
28
26
-
29
+
30
+ # function to search records in mysql tables
27
31
def Search_Records ():
28
32
con = connection ()
29
33
cursor = con .cursor ()
30
34
CID = e1 .get ()
31
- query = ("select * from items where CID=%s" )
35
+ query = ("select * from items where CID=%s" ) #executive the querry
32
36
data = (CID ,)
33
37
cursor .execute (query ,data )
34
38
dasd = cursor .fetchall ()
@@ -38,7 +42,7 @@ def Search_Records():
38
42
39
43
40
44
41
-
45
+ # function to Insert records in mysql tables
42
46
def Insert_Records ():
43
47
con = connection ()
44
48
cursor = con .cursor ()
@@ -58,7 +62,7 @@ def Insert_Records():
58
62
con .commit ()
59
63
con .close ()
60
64
61
-
65
+ # function to show all records in mysql tables
62
66
def show_money ():
63
67
con = connection ()
64
68
cur = con .cursor ()
@@ -72,7 +76,8 @@ def show_money():
72
76
cur .close ()
73
77
con .commit ()
74
78
con .close ()
75
-
79
+
80
+ #Function To delete the records
76
81
def delete ():
77
82
con = connection ()
78
83
cur = con .cursor ()
@@ -93,17 +98,20 @@ def delete():
93
98
def close ():
94
99
sys .exit ()
95
100
101
+ #Starting the UI Work........
102
+
96
103
97
104
root = Tk ()
98
105
root .title ("KHATA BOOK SOFT" )
99
-
106
+ #decalring the variables...
100
107
CID = StringVar ()
101
108
Customer_Name = StringVar ()
102
109
Item1 = StringVar ()
103
110
worth1 = StringVar ()
104
111
Item2 = StringVar ()
105
112
worth2 = StringVar ()
106
113
114
+ #making the labels for fields in UI...........
107
115
108
116
label1 = Label (root ,text = "Customer ID" ,font = "arial 10 bold" )
109
117
label1 .place (x = 0 ,y = 0 )
@@ -123,6 +131,7 @@ def close():
123
131
label16 = Label (root ,text = "worth2" ,font = "arial 10 bold" )
124
132
label16 .place (x = 0 ,y = 150 )
125
133
134
+ # MAking th entry field .........
126
135
e1 = Entry (root ,textvariable = CID ,bg = "lightblue" )
127
136
e1 .place (x = 120 ,y = 0 )
128
137
@@ -142,10 +151,12 @@ def close():
142
151
e6 .place (x = 120 ,y = 150 )
143
152
144
153
145
-
154
+ # OUTPUT AREA....................
146
155
t1 = Text (root ,width = 80 ,height = 20 ,bg = "green" ,font = "arial 10 bold" )
147
156
t1 .grid (row = 9 ,column = 1 )
148
157
158
+ #Buttons That Triggers the Functions............
159
+
149
160
b1 = Button (root ,text = "Seacrch CUSTOMER" ,command = Search_Records ,width = 40 ,bg = "orange" ,font = "arial 10 bold" )
150
161
b1 .grid (row = 11 ,column = 0 )
151
162
0 commit comments