Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. import os, random
  2. from random import choice
  3. import winsound
  4. import time
  5. from tkinter import *
  6.  
  7. master = Tk()
  8.  
  9. question = "What is the correct Arabic letter?"
  10.  
  11. Imagepath = "C:\LearnArabic\alphabet\Image\"
  12. Soundpath = "C:\LearnArabic\alphabet\Sound\"
  13. Letter = random.choice(os.listdir(Soundpath))
  14. winsound.PlaySound((Soundpath)+ (Letter), winsound.SND_FILENAME)
  15.  
  16. def answers(question, possAnswers):
  17. print(question)
  18. answerList = ["answer1", "answer2", "answer3", "correct"]
  19. random.shuffle(answerList)
  20.  
  21. for i,j in enumerate(answerList):
  22. print("%s: %s" %(i, possAnswers[j]))
  23.  
  24. inp = int(input(">>> "))
  25.  
  26. if answerList[inp] == "correct":
  27. print("Correct!")
  28. IL = (Imagepath + (Letter.rsplit(".", 1)[0])+ ".png")
  29. label = Label(master, image=IL, anchor = E)
  30. label.image = (IL)
  31. label.grid(row = 2, column = 0, sticky = S)
  32.  
  33. if answerList[inp] != "correct":
  34. print("Try again fool")
  35. print("The corect answer was: ", Letter)
  36. IL = (Imagepath + (Letter.rsplit(".", 1)[0])+ ".png")
  37. label = Label(master, image=IL, anchor = E)
  38. label.image = (IL)
  39. label.grid(row = 2, column = 0, sticky = S)
  40.  
  41. possAnswers = {"answer1" : random.choice(os.listdir(Soundpath)), "answer2" : random.choice(os.listdir(Soundpath)), "answer3" : random.choice(os.listdir(Soundpath)), "correct" : Letter}
  42. answers(question, possAnswers)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement