Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, random
- from random import choice
- import winsound
- import time
- from tkinter import *
- master = Tk()
- question = "What is the correct Arabic letter?"
- Imagepath = "C:\LearnArabic\alphabet\Image\"
- Soundpath = "C:\LearnArabic\alphabet\Sound\"
- Letter = random.choice(os.listdir(Soundpath))
- winsound.PlaySound((Soundpath)+ (Letter), winsound.SND_FILENAME)
- def answers(question, possAnswers):
- print(question)
- answerList = ["answer1", "answer2", "answer3", "correct"]
- random.shuffle(answerList)
- for i,j in enumerate(answerList):
- print("%s: %s" %(i, possAnswers[j]))
- inp = int(input(">>> "))
- if answerList[inp] == "correct":
- print("Correct!")
- IL = (Imagepath + (Letter.rsplit(".", 1)[0])+ ".png")
- label = Label(master, image=IL, anchor = E)
- label.image = (IL)
- label.grid(row = 2, column = 0, sticky = S)
- if answerList[inp] != "correct":
- print("Try again fool")
- print("The corect answer was: ", Letter)
- IL = (Imagepath + (Letter.rsplit(".", 1)[0])+ ".png")
- label = Label(master, image=IL, anchor = E)
- label.image = (IL)
- label.grid(row = 2, column = 0, sticky = S)
- possAnswers = {"answer1" : random.choice(os.listdir(Soundpath)), "answer2" : random.choice(os.listdir(Soundpath)), "answer3" : random.choice(os.listdir(Soundpath)), "correct" : Letter}
- answers(question, possAnswers)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement