-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectCodefinal.py
More file actions
1587 lines (1397 loc) · 51.2 KB
/
ProjectCodefinal.py
File metadata and controls
1587 lines (1397 loc) · 51.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from tkinter import *
import tkinter as tk
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure
import tkinter as tk
from PIL import ImageTk,Image
import sqlite3
import re
from nltk.corpus import stopwords
from nltk.sentiment import SentimentIntensityAnalyzer
from nltk.stem import PorterStemmer
from tkinter import ttk
import matplotlib.pyplot as plt
root=Tk()
root.title("Reviewing System")
root.iconbitmap()
root.geometry("200x200")
global ward
ward=0
#create a database or connect to one
conn=sqlite3.connect('Details.db')
#create cursor
c=conn.cursor()
root.geometry("500x600")
frame = Frame(root,bg='red')
frame.grid(row=20,column=20)
msg = Label(text = "MULTI REVIEWING SYSTEM",font = ("Algerian",30),bg = 'LightSkyBlue2')
msg.place(x=500,y=10)
#function for displaying result
def final_ward():
global resulter
resulter=Tk()
resulter.title("Fetch Result")
resulter.iconbitmap()
resulter.geometry("400x250")
global res_label
global res_box
res_label=Label(resulter,text="Enter Name ")
res_label.place(relx=0.3,rely=0.4)
res_box=Entry(resulter,width=30)
res_box.place(relx=0.5,rely=0.4)
res_btn=Button(resulter,text="Fetch",command=final_searchward,fg="Green",activebackground = "black")
res_btn.place(relx=0.45,rely=0.85)
def create_charts_ward():
pier= tk.Tk()
canvas1 = tk.Canvas(pier, width = 100, height = 40)
canvas1.pack()
pier.title("Wardrobe result pie chart")
label1 = tk.Label(pier, text='Graphical User Interface')
label1.config(font=('Arial', 20))
global x1
global x2
global x3
global bar1
global pie2
x1 = float(res_zero)
x2 = float(res_one)
x3 = float(res_two)
figure2 = Figure(figsize=(4,3), dpi=100)
subplot2 = figure2.add_subplot(111)
labels2 = 'Negative', 'Positive', 'Neutral'
pieSizes = [float(x1),float(x2),float(x3)]
my_colors2 = ['lightblue','lightsteelblue','silver']
explode2 = (0, 0.1, 0)
subplot2.pie(pieSizes, colors=my_colors2, explode=explode2, labels=labels2, autopct='%1.1f%%', shadow=True, startangle=90)
subplot2.axis('equal')
pie2 = FigureCanvasTkAgg(figure2, pier)
pie2.get_tk_widget().pack()
pier.mainloop()
def clear_charts():
bar1.get_tk_widget().pack_forget()
pie2.get_tk_widget().pack_forget()
def final_searchward():
global res_res
res_res=res_box.get()
conn=sqlite3.connect('Details.db')
#create cursor
c=conn.cursor()
query_res= f"SELECT * FROM Wardrobe WHERE name='{res_res}';"
c.execute(query_res)
res_record=c.fetchone()
global res_zero
global res_one
global res_two
res_zero=res_record[4]
res_one=res_record[3]
res_two=res_record[5]
slices=[res_two,res_one,res_zero]#the final neutral,positive,negative value shoud be passed here
outputs=['negative','positive','neutral']
cols=['c','m','b']
plt.pie(slices,labels=outputs,colors=cols,startangle=90,shadow=True,explode=(0,0.1,0),autopct='%1.1f%%')
plt.title("Final result")
plt.show()
create_charts_ward()
def prop(n):
return 360.0 * n / 1000
#function for uploading image into db for client side
def ward_upload():
global ward_editor_upload
ward_editor_upload=Tk()
ward_editor_upload.title("To Upload Wardrobe Image")
ward_editor_upload.iconbitmap()
ward_editor_upload.geometry("400x250")
#create a database or connect to one
conn=sqlite3.connect('Details.db')
#create cursor
c=conn.cursor()
global val_label_1
global val_box_1
global name_label_1
global name_box_1
global image_address_1
name_label_1=Label(ward_editor_upload,text="Enter name :")
name_label_1.grid(row=1,column=3)
name_box_1=Entry(ward_editor_upload,width=30)
name_box_1.grid(row=1,column=5)
val_label_1=Label(ward_editor_upload,text="Enter location image present:")
val_label_1.grid(row=3,column=3)
val_box_1=Entry(ward_editor_upload,width=30)
val_box_1.grid(row=3,column=5)
image_address_1=val_box_1.get()
print(image_address_1)
'''
#image_name_1=name_box_1.get("1.0","end-1c")
ttk.Label(ward_editor_upload, text="Enter your Review :",
font=("Times New Roman", 15)).place(relx=0.15,rely=0.75)
# Text Widget
global tl
tl = Text(ward_editor_upload, width=100, height=6)
tl.place(relx=0.3,rely=0.7)
tl.focus()'''
upld_btn=Button(ward_editor_upload,text="UPLOAD",command=retrieve_input_1,fg="Green",activebackground = "black")
upld_btn.grid(row=5,column=4)
#function to retrive input from client
def retrieve_input_1():
#image_address_1=tl.get("1.0","end-1c")
global image_name_1
global image_address_1
image_name_1=name_box_1.get()
image_address_1=val_box_1.get()
print(image_name_1)
print(image_address_1)
upld_2_btn=Button(ward_editor_upload,text="Confirm UPLOAD ",command=insertWard(image_name_1,image_address_1),fg="Green",activebackground = "black")
upld_2_btn.grid(row=6,column=5)
# Function for Convert Binary Data
# to Human Readable Format
def convertToBinaryData(filename):
# Convert binary format to images
# or files data
with open(filename, 'rb') as file:
blobData = file.read()
return blobData
def insertWard(name, photo):
try:
# Using connect method for establishing
# a connection
sqliteConnection = sqlite3.connect('Details.db')
cursor = sqliteConnection.cursor()
print("Connected to SQLite")
# insert query
sqlite_insert_blob_query = """ INSERT INTO Wardrobe
(name,image,ones,zeros,twos) VALUES (?,?,0,0,0)"""
# Converting human readable file into
# binary data
empPhoto = convertToBinaryData(photo)
# Convert data into tuple format
data_tuple = (name, empPhoto)
# using cursor object executing our query
cursor.execute(sqlite_insert_blob_query, data_tuple)
sqliteConnection.commit()
print("Image and file inserted successfully as a BLOB into a table")
global success_label
success_label=Label(ward_editor_upload,text="Image and file inserted successfully ..")
success_label.grid(row=9,column=7)
cursor.close()
except sqlite3.Error as error:
print("Failed to insert blob data into sqlite table", error)
global fail_label
fail_label=Label(ward_editor_upload,text="Failed to insert")
fail_label.grid(row=9,column=7)
finally:
if sqliteConnection:
sqliteConnection.close()
print("the sqlite connection is closed")
#insertBLOB("Smith", "D:\Internship Tasks\GFG\images\One.png")
#function for reviewer side wardrobe
def ward_list_items():
global ward_editor
ward_editor=Tk()
ward_editor.title("To Review Wardrobe List")
ward_editor.iconbitmap()
ward_editor.geometry("400x250")
#create a database or connect to one
conn=sqlite3.connect('Details.db')
#create cursor
c=conn.cursor()
global n
global val_label
global val_box
val_label=Label(ward_editor,text="Enter location where you want to download:")
val_label.place(relx=0.15,rely=0.35)
val_box=Entry(ward_editor,width=30)
val_box.place(relx=0.35,rely=0.35)
n=val_box.get()
down_btn=Button(ward_editor,text="DOWNLOAD",command=ward_list,fg="Green",activebackground = "black")
down_btn.place(relx=0.45,rely=0.4)
def ward_list():
try:
# Using connect method for establishing
# a connection
con = sqlite3.connect('Details.db')
cursor = con.cursor()
print("Connected Successfully")
query2=f"SELECT ward_image from Login_details WHERE userid='{username}' AND passcode ='{password}';"
cursor.execute(query2)
global last_image_ward
global ward_oid
last_image_ward=cursor.fetchone()
print(last_image_ward)
global last_ward
last_ward=int(last_image_ward[0])
last_ward+=1
# Search from table query
query = f"SELECT * FROM Wardrobe WHERE oid={last_ward}"
# using cursor object executing our query
cursor.execute(query)
# fectching all records from cursor object
records = cursor.fetchall()
ward_oid=last_ward
# using for loop retrieving one by one
# rows or data
for row in records:
# storing row[0] in name variable
name = row[0]
#print(row)
#present_ones=row[3]
# printing name variable
print("Image Name = ", name)
# storing image (currently in binary format)
image = row[1]
# calling above convert_data() for converting
# binary data to human readable
convert_data(image, n + name + ".png")
print("Yeah!! We have successfully retrieved values from database")
# If we don't have any records in our database,
# then print this
if len(records) == 0:
print("Sorry! Please Insert some data before reading from the database.")
# print exception if found any during program
# is running
except sqlite3.Error as error:
print(format(error))
# using finally, closing the connection
# (con) object
finally:
if con:
con.close()
print("SQLite connection is closed")
#ward_list_items()
global ward_num
limit=0
ward_num=0
global val1_label
val1_label=Label(ward_editor,text="IMAGE "+name)
val1_label.place(relx=0.3,rely=0.6)
ttk.Label(ward_editor, text="Enter your Review :",
font=("Times New Roman", 15)).place(relx=0.15,rely=0.75)
# Text Widget
global t
t = Text(ward_editor, width=100, height=6)
t.place(relx=0.3,rely=0.7)
t.focus()
down_btn=Button(ward_editor,text="Submit",command=lambda:retrieve_input(),fg="Green",activebackground = "black")
down_btn.place(relx=0.45,rely=0.85)
#command=lambda: retrieve_input()
def retrieve_input():
#print("hello")
n=val_box.get()
#print(n)
inputValue=t.get("1.0","end-1c")
result=senti(inputValue)
global final_ward_label
final_ward_label=Label(ward_editor,text="Review Has been saved , click on close ")
final_ward_label.place(relx=0.5,rely=0.9)
#we need to add data after creating wardrobe table
t.delete(1.0,END)
if(result==1):
#present_ones+=1
conn=sqlite3.connect('Details.db')
#create cursor
c=conn.cursor()
query1= f"SELECT ones FROM Wardrobe WHERE oid={ward_oid}"
c.execute(query1)
present_ones=c.fetchone()
print(present_ones)
present_one=int(present_ones[0])
present_one+=1
print(present_one)
c.execute(f"""UPDATE Wardrobe SET
ones=:ones
WHERE oid={ward_oid}""",
{
'ones':present_one
}
)
#commit changes
conn.commit()
#close connection
conn.close()
elif(result==0):
#present_ones+=1
conn=sqlite3.connect('Details.db')
#create cursor
c=conn.cursor()
query1= f"SELECT zeros FROM Wardrobe WHERE oid={ward_oid}"
c.execute(query1)
global present_zeros
present_zeros=c.fetchone()
print(present_zeros)
present_zero=int(present_zeros[0])
present_zero+=1
print(present_zero)
c.execute(f"""UPDATE Wardrobe SET
zeros=:zeros
WHERE oid={ward_oid}""",
{
'zeros':present_zero
}
)
#commit changes
conn.commit()
#close connection
conn.close()
elif(result==2):
#present_ones+=1
conn=sqlite3.connect('Details.db')
#create cursor
c=conn.cursor()
query1= f"SELECT twos FROM Wardrobe WHERE oid={ward_oid}"
c.execute(query1)
global present_twos
present_twos=c.fetchone()
print(present_twos)
present_two=int(present_twos[0])
present_two+=1
print(present_two)
c.execute(f"""UPDATE Wardrobe SET
twos=:twos
WHERE oid={ward_oid}""",
{
'twos':present_two
}
)
#commit changes
conn.commit()
#close connection
conn.close()
#create a database or connect to one
conn=sqlite3.connect('Details.db')
#create cursor
c=conn.cursor()
c.execute(f"""UPDATE Login_details SET
ward_image=:ward_image
WHERE userid={username} AND passcode={password}""",
{
'ward_image':last_ward
}
)
#commit changes
conn.commit()
#close connection
conn.close()
ward_editor.mainloop()
#ward_editor.destroy()
#ward_editor.destroy()
#function to upload image into database
# Function for Convert Binary
# Data to Human Readable Format
def convert_data(data, file_name):
# Convert binary format to
# images or files data
with open(file_name, 'wb') as file:
file.write(data)
img = Image.open(file_name)
print(img)
#sentimental analysis
def senti(inputvalue):
data=inputvalue
stop_words = set(stopwords.words('english'))
stop_words.remove("not")
data.lower()
dat=list(data.split())
#word_tokens = word_tokenize(data)
corpus=[]
ps = PorterStemmer()
print(data)
for i in range(0,len(dat)):
review = re.sub('[^a-zA-Z]',' ', dat[i])
if(review not in set(stop_words)):
corpus.append(review)
print(corpus)
sid = SentimentIntensityAnalyzer()
pos_word_list=[]
neu_word_list=[]
neg_word_list=[]
for word in corpus:
print(sid.polarity_scores(word))
if (sid.polarity_scores(word)['compound']) >= 0.4:
pos_word_list.append(word)
elif (sid.polarity_scores(word)['compound']) <= -0.4:
neg_word_list.append(word)
else:
neu_word_list.append(word)
if(len(pos_word_list)>len(neg_word_list)):
return 1
elif(len(pos_word_list)<len(neg_word_list)):
return 0
else:
return 2
def update():
#create a database or connect to one
conn=sqlite3.connect('Details.db')
#create cursor
c=conn.cursor()
#record_id=user.get()
c.execute("""UPDATE Login_details SET
userid=:userid,
passcode=:passcode,
name=:name,
phone=:phone,
address=:address
WHERE userid=:userid AND passcode=:passcode""",
{
'userid':userid_editor1.get(),
'passcode':passcode_editor1.get(),
'name':name_editor1.get(),
'phone':phone_editor1.get(),
'address':address_editor1.get()
}
)
#commit changes
conn.commit()
#close connection
conn.close()
editor.destroy()
#delete_box.delete(0,END)
def edit_details():
global name_login_box
global passcode_login_box
#create textboxes
name_login_box=Entry(root,width=30)
name_login_box.place(relx=0.4,rely=0.4)
#passcode text code
passcode_login_box=Entry(root,width=30,show='*')
passcode_login_box.place(relx=0.4,rely=0.5)
#label for userid
name_login_label=Label(root,text="USER ID")
name_login_label.place(relx=0.3,rely=0.4)
#label for passcode in login
passcode_login_label=Label(root,text="passcode")
passcode_login_label.place(relx=0.3,rely=0.5)
#create Login button
login_btn2=Button(root,text="submit",command=edit)
login_btn2.place(relx=0.47,rely=0.55)
name_login_box.delete(0,END)
passcode_login_box.delete(0,END)
#create an edit function to update a record
def edit():
global record_id
global record_passcode
record_id=name_login_box.get()
record_passcode=passcode_login_box.get()
global editor
editor=Tk()
editor.title("Update A Record")
editor.iconbitmap()
editor.geometry("400x250")
#create a database or connect to one
conn=sqlite3.connect('Details.db')
#create cursor
c=conn.cursor()
#Query the database
statement=f"SELECT * FROM Login_details WHERE userid='{record_id}' AND passcode = '{record_passcode}'"
c.execute(statement)
records=c.fetchall()
#print("hi")
#create global variables for text box names
global name_editor1
global phone_editor1
global address_editor1
global userid_editor1
global passcode_editor1
#create text boxes
userid_editor1=Entry(editor,width=30)
userid_editor1.grid(row=1,column=1)
passcode_editor1=Entry(editor,width=30)
passcode_editor1.grid(row=2,column=1)
name_editor1=Entry(editor,width=30)
name_editor1.grid(row=3,column=1,padx=20,pady=(10,0))
phone_editor1=Entry(editor,width=30)
phone_editor1.grid(row=4,column=1)
address_editor1=Entry(editor,width=30)
address_editor1.grid(row=5,column=1)
#create TextBox Labels
userid_label=Label(editor,text="User id")
userid_label.grid(row=1,column=0)
passcode_label=Label(editor,text="passcode")
passcode_label.grid(row=2,column=0)
name_label=Label(editor,text="Name")
name_label.grid(row=3,column=0,pady=(10,0))
phone_label=Label(editor,text="Phone Number")
phone_label.grid(row=4,column=0)
address_label=Label(editor,text="Address")
address_label.grid(row=5,column=0)
#create a Save button to save edited record
#Loop thru results
for record in records:
userid_editor1.insert(0,record[0])
passcode_editor1.insert(0,record[1])
name_editor1.insert(0,record[2])
phone_editor1.insert(0,record[3])
address_editor1.insert(0,record[4])
edit_btn=Button(editor,text="Save Record",command=update)
edit_btn.grid(row=14,column=1,columnspan=2,pady=10,padx=10,ipadx=145)
#name_login_box.delete(0,END)
#passcode_login_box.delete(0,END)
#commit changes
conn.commit()
#close connection
conn.close()
#function for adding record into database
def submit():
#create a database or connect to one
conn=sqlite3.connect('Details.db')
#create cursor
c=conn.cursor()
#insert into table
c.execute("INSERT INTO Login_details VALUES (:userid,:passcode,:name,:phone,:address,:ward_image,:design_image,:new_image)",
{
'userid': userid_editor.get(),
'passcode':passcode_editor.get(),
'name':name_editor.get(),
'phone':phone_editor.get(),
'address':address_editor.get(),
'ward_image':'0',
'design_image':'0',
'new_image':'0'
})
#commit changes
conn.commit()
#close connection
conn.close()
#clear the text boxes
userid_editor.delete(0,END)
passcode_editor.delete(0,END)
name_editor.delete(0,END)
phone_editor.delete(0,END)
address_editor.delete(0,END)
adder.destroy()
def final_design():
global resulter1
resulter1=Tk()
resulter1.title("Fetch Result")
resulter1.iconbitmap()
resulter1.geometry("400x250")
global res_label
global res_box
res_label=Label(resulter1,text="Enter Name ")
res_label.place(relx=0.3,rely=0.4)
res_box=Entry(resulter1,width=30)
res_box.place(relx=0.5,rely=0.4)
res_btn=Button(resulter1,text="Fetch",command=final_searchdesign,fg="Green",activebackground = "black")
res_btn.place(relx=0.45,rely=0.85)
def create_charts_design():
pier= tk.Tk()
canvas1 = tk.Canvas(pier, width = 100, height = 40)
canvas1.pack()
label1 = tk.Label(pier, text='Graphical User Interface')
label1.config(font=('Arial', 20))
global x1
global x2
global x3
global bar1
global pie2
x1 = float(res_zero)
x2 = float(res_one)
x3 = float(res_two)
figure2 = Figure(figsize=(4,3), dpi=100)
subplot2 = figure2.add_subplot(111)
labels2 = 'Negative', 'Positive', 'Neutral'
pieSizes = [float(x1),float(x2),float(x3)]
my_colors2 = ['lightblue','lightsteelblue','silver']
explode2 = (0, 0.1, 0)
subplot2.pie(pieSizes, colors=my_colors2, explode=explode2, labels=labels2, autopct='%1.1f%%', shadow=True, startangle=90)
subplot2.axis('equal')
pie2 = FigureCanvasTkAgg(figure2, pier)
pie2.get_tk_widget().pack()
pier.mainloop()
def clear_charts():
bar1.get_tk_widget().pack_forget()
pie2.get_tk_widget().pack_forget()
def final_searchdesign():
global res_res
res_res=res_box.get()
conn=sqlite3.connect('Details.db')
#create cursor
c=conn.cursor()
query_res= f"SELECT * FROM Design WHERE name='{res_res}';"
c.execute(query_res)
res_record=c.fetchone()
global res_zero
global res_one
global res_two
res_zero=res_record[4]
res_one=res_record[3]
res_two=res_record[5]
slices=[res_two,res_one,res_zero]#the final neutral,positive,negative value shoud be passed here
outputs=['negative','positive','neutral']
cols=['c','m','b']
plt.pie(slices,labels=outputs,colors=cols,startangle=90,shadow=True,explode=(0,0.1,0),autopct='%1.1f%%')
plt.title("Final result")
plt.show()
create_charts_design()
def prop(n):
return 360.0 * n / 1000
#function for uploading image into db for client side
def design_upload():
global design_editor_upload
design_editor_upload=Tk()
design_editor_upload.title("To Upload Wardrobe Image")
design_editor_upload.iconbitmap()
design_editor_upload.geometry("400x250")
#create a database or connect to one
conn=sqlite3.connect('Details.db')
#create cursor
c=conn.cursor()
global val_label_12
global val_box_12
global name_label_12
global name_box_12
global image_address_12
name_label_12=Label(design_editor_upload,text="Enter name :")
name_label_12.grid(row=1,column=3)
name_box_12=Entry(design_editor_upload,width=50)
name_box_12.grid(row=1,column=5)
val_label_12=Label(design_editor_upload,text="Enter location image present:")
val_label_12.grid(row=3,column=3)
val_box_12=Entry(design_editor_upload,width=50)
val_box_12.grid(row=3,column=5)
image_address_12=val_box_12.get()
print(image_address_12)
'''
#image_name_1=name_box_1.get("1.0","end-1c")
ttk.Label(ward_editor_upload, text="Enter your Review :",
font=("Times New Roman", 15)).place(relx=0.15,rely=0.75)
# Text Widget
global tl
tl = Text(ward_editor_upload, width=100, height=6)
tl.place(relx=0.3,rely=0.7)
tl.focus()'''
upld_btn=Button(design_editor_upload,text="UPLOAD",command=retrieve_input_12,fg="Green",activebackground = "black")
upld_btn.grid(row=5,column=4)
#function to retrive input from client
def retrieve_input_12():
#image_address_1=tl.get("1.0","end-1c")
global image_name_12
global image_address_12
image_name_12=name_box_12.get()
image_address_12=val_box_12.get()
print(image_name_12)
print(image_address_12)
upld_2_btn=Button(design_editor_upload,text="Confirm UPLOAD ",command=insertdesign(image_name_12,image_address_12),fg="Green",activebackground = "black")
upld_2_btn.grid(row=6,column=5)
def insertdesign(name, photo):
try:
# Using connect method for establishing
# a connection
sqliteConnection = sqlite3.connect('Details.db')
cursor = sqliteConnection.cursor()
print("Connected to SQLite")
# insert query
sqlite_insert_blob_query = """ INSERT INTO Design
(name,image,ones,zeros,twos) VALUES (?,?,0,0,0)"""
# Converting human readable file into
# binary data
empPhoto = convertToBinaryData(photo)
# Convert data into tuple format
data_tuple = (name, empPhoto)
# using cursor object executing our query
cursor.execute(sqlite_insert_blob_query, data_tuple)
sqliteConnection.commit()
print("Image and file inserted successfully as a BLOB into a table")
global success_label_1
success_label_1=Label(design_editor_upload,text="Image and file inserted successfully ..")
success_label_1.grid(row=9,column=7)
cursor.close()
except sqlite3.Error as error:
print("Failed to insert blob data into sqlite table", error)
global fail_label_1
fail_label_1=Label(design_editor_upload,text="Failed to insert")
fail_label_1.grid(row=9,column=7)
finally:
if sqliteConnection:
sqliteConnection.close()
print("the sqlite connection is closed")
#insertBLOB("Smith", "D:\Internship Tasks\GFG\images\One.png")
#function for reviewer side wardrobe
def design_list_items():
global design_editor
design_editor=Tk()
design_editor.title("To Review Art And Design")
design_editor.iconbitmap()
design_editor.geometry("400x250")
#create a database or connect to one
conn=sqlite3.connect('Details.db')
#create cursor
c=conn.cursor()
global n
global val_label
global val_box
val_label=Label(design_editor,text="Enter location where you want to download:")
val_label.place(relx=0.15,rely=0.35)
val_box=Entry(design_editor,width=30)
val_box.place(relx=0.35,rely=0.35)
n=val_box.get()
down_btn=Button(design_editor,text="DOWNLOAD",command=design_list,fg="Green",activebackground = "black")
down_btn.place(relx=0.45,rely=0.4)
def design_list():
try:
# Using connect method for establishing
# a connection
con = sqlite3.connect('Details.db')
cursor = con.cursor()
print("Connected Successfully")
query2=f"SELECT design_image from Login_details WHERE userid='{username}' AND passcode ='{password}';"
cursor.execute(query2)
global last_image_design
global design_oid
last_image_design=cursor.fetchone()
print(last_image_design)
global last_design
last_design=int(last_image_design[0])
last_design+=1
# Search from table query
query = f"SELECT * FROM Design WHERE oid={last_design}"
# using cursor object executing our query
cursor.execute(query)
# fectching all records from cursor object
records = cursor.fetchall()
design_oid=last_design
# using for loop retrieving one by one
# rows or data
for row in records:
# storing row[0] in name variable
name = row[0]
#print(row)
#present_ones=row[3]
# printing name variable
print("Image Name = ", name)
# storing image (currently in binary format)
image = row[1]
# calling above convert_data() for converting
# binary data to human readable
convert_data(image, n + name + ".png")
print("Yeah!! We have successfully retrieved values from database")
# If we don't have any records in our database,
# then print this
if len(records) == 0:
print("Sorry! Please Insert some data before reading from the database.")
# print exception if found any during program
# is running
except sqlite3.Error as error:
print(format(error))
# using finally, closing the connection
# (con) object
finally:
if con:
con.close()
print("SQLite connection is closed")
#ward_list_items()
global design_num
limit=0
design_num=0
global val1_label
val1_label=Label(design_editor,text="Art And Design IMAGE")
val1_label.place(relx=0.3,rely=0.6)
ttk.Label(design_editor, text="Enter your Review :",
font=("Times New Roman", 15)).place(relx=0.15,rely=0.75)
# Text Widget
global t1
t1= Text(design_editor, width=100, height=6)
t1.place(relx=0.3,rely=0.7)
t1.focus()
down_btn=Button(design_editor,text="Submit",command=lambda:retrieve_input_design(),fg="Green",activebackground = "black")
down_btn.place(relx=0.45,rely=0.85)
#command=lambda: retrieve_input()
def retrieve_input_design():
#print("hello")
n=val_box.get()
#print(n)
inputValue=t1.get("1.0","end-1c")
result=senti(inputValue)
global final_design_label
final_design_label=Label(design_editor,text="Review Has been saved , click on close ")
final_design_label.place(relx=0.5,rely=0.9)
#we need to add data after creating wardrobe table
t1.delete(1.0,END)
if(result==1):
#present_ones+=1
conn=sqlite3.connect('Details.db')
#create cursor
c=conn.cursor()
query1= f"SELECT ones FROM Design WHERE oid={design_oid}"
c.execute(query1)
present_ones_1=c.fetchone()
print(present_ones_1)
present_one_1=int(present_ones_1[0])
present_one_1+=1
print(present_one_1)
c.execute(f"""UPDATE Design SET
ones=:ones
WHERE oid={design_oid}""",
{
'ones':present_one_1
}
)
#commit changes
conn.commit()
#close connection
conn.close()
elif(result==0):
#present_ones+=1
conn=sqlite3.connect('Details.db')
#create cursor
c=conn.cursor()
query1= f"SELECT zeros FROM Design WHERE oid={design_oid}"
c.execute(query1)
global present_zeros_1
present_zeros_1=c.fetchone()
print(present_zeros_1)
present_zero_1=int(present_zeros_1[0])
present_zero_1+=1
print(present_zero_1)
c.execute(f"""UPDATE Design SET
zeros=:zeros
WHERE oid={design_oid}""",
{
'zeros':present_zero_1
}
)
#commit changes
conn.commit()
#close connection
conn.close()
elif(result==2):
#present_ones+=1
conn=sqlite3.connect('Details.db')
#create cursor
c=conn.cursor()
query1= f"SELECT twos FROM Design WHERE oid={design_oid}"
c.execute(query1)
global present_twos_1
present_twos_1=c.fetchone()
print(present_twos_1)
present_two_1=int(present_twos_1[0])
present_two_1+=1
print(present_two_1)
c.execute(f"""UPDATE Design SET
twos=:twos
WHERE oid={design_oid}""",
{
'twos':present_two_1
}
)
#commit changes
conn.commit()
#close connection
conn.close()
#create a database or connect to one