Aryan_Bisht

Untitled

May 14th, 2021
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. import pyttsx3
  2. from plyer import notification
  3. import time
  4. import openpyxl
  5. import inflect
  6. from tkinter import *
  7. from PyQt5.QtCore import QObject, QThread, pyqtSignal
  8. import threading
  9. import sys, os
  10.  
  11.  
  12. root = Tk()
  13. root.title('Vocabulary tutor')
  14. root.geometry("700x700")
  15. root.configure(background='gray27')
  16.  
  17. def submit():
  18. background = threading.Thread(target=values,args=(my_box1.get(),int(my_box2.get()),))
  19. background.start()
  20.  
  21. read="""Welcome to Vocabulary Tutor,
  22. this app allows you to set the timer.
  23. You will be notified with an english
  24. word and its meaning after every
  25. specified time.Please fill the below
  26. requirements to continue... """
  27.  
  28. my_label0 = Label(root, text=read, font=("Courier",18,"bold italic"),fg="light cyan",bg="gray27")
  29. my_label0.pack(pady=20)
  30.  
  31. my_label1 = Label(root, text="Enter your name", font=("Helvetica",18),fg="gold",bg="gray27")
  32. my_label1.pack(pady=20)
  33.  
  34. my_box1 = Entry(root)
  35. my_box1.pack(pady=20)
  36.  
  37. my_label = Label(root, text="Set the timer (in sec)", font=("Times bold",18),fg = "gold",bg="gray27")
  38. my_label.pack(pady=20)
  39.  
  40. my_box2 = Entry(root)
  41. my_box2.pack(pady=20)
  42.  
  43. my_button = Button(root,text="Submit",fg='gray1', bg='PaleVioletRed1' ,activebackground='lawn green',command=submit)
  44. my_button.pack(pady=50)
  45.  
  46. exit_button= Button(root, text="Exit", command=root.destroy)
  47. exit_button.pack(pady=20)
  48.  
  49. p=inflect.engine()
  50.  
  51. file_location="list.xlsx"
  52. workbook=openpyxl.load_workbook(file_location)
  53. sheet=workbook.active
  54.  
  55. def notify(title,message):
  56. notification.notify(title=title,message=message,app_icon="icon3.ico",timeout = 15,)
  57.  
  58. engine = pyttsx3.init()
  59. voices = engine.getProperty('voices')
  60. engine.setProperty('voice',voices[1].id)
  61. engine.setProperty("rate",135)
  62. engine.setProperty("volume",1.0)
  63.  
  64. f = True
  65.  
  66. def threadWork(timer):
  67. global f
  68. f = False
  69.  
  70. time.sleep(timer)
  71.  
  72. f = True
  73.  
  74. def values(n,t):
  75. name=n
  76. timer=t
  77. value1 = 1
  78. i=1
  79. while True:
  80. global f
  81.  
  82. if f:
  83. value2=1
  84. call_obj1=sheet.cell(row=value1,column=value2)
  85. call_obj2=sheet.cell(row=value1,column=value2+1)
  86. msg="__WORD__: "+call_obj1.value+"\n\n__MEANING__: "+call_obj2.value
  87. sheet.delete_rows(value1)
  88. workbook.save('list.xlsx')
  89. text="hellow " + name + f" here is your {p.ordinal(i)} word "
  90. engine.say(text)
  91. notify("VOCABULARY",msg)
  92. engine.runAndWait()
  93. value1=value1+1
  94. i=i+1
  95. newThread = threading.Thread(target=threadWork, args=(timer,))
  96. newThread.start()
  97.  
  98.  
  99. newThread.join()
  100.  
  101.  
  102. root.mainloop()
  103.  
Add Comment
Please, Sign In to add comment