Last active
August 15, 2020 07:59
-
-
Save ssaisriharsha/b9b8bfb9320f88a52b6f2611c24b1ff7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# importing libraries or modules | |
from tkinter import* | |
# creating window | |
root = Tk() | |
root.title("quiz for 10th f1 students".upper()) | |
root.iconbitmap("images/10th f1.ico") | |
root.resizable(0, 0) | |
# creating questions | |
Q1 = "WHOSE PC IS THE WORST PC IN OUR CLASS?" | |
Q2 = "WHO IS THE MOST UNLUCKY PERSON IN OUR CLASS?" | |
Q3 = "WHO IS THE MOST DISLIKED PERSON IN OUR CLASS?" | |
Q4 = "WHO USES THE WORD 'WHAT THE' MORE TIME IN OUR TEACHER?" | |
Q5 = "WHICH ANIME IS MOST WATCHED IN OUR CLASS?" | |
my_Q1 = Label(root, text=Q1, font="Times_New_Roman, 10") | |
my_Q1.grid(row=0, column=0) | |
# creating question list | |
q_list = [Q1, Q2, Q3, Q4, Q5] | |
# creating score variable | |
score ="YOUR SCORE IS:\n 0" | |
# creating submit function | |
def submit(): | |
global my_Q1 | |
global submit_button | |
my_Q1.grid_forget() | |
submit_button = Button(root, text="SUBMIT", anchor=E, command=lambda: submit(), state=DISABLED) | |
submit_button.grid(row=5, column=0, sticky=E, padx=5, pady=5) | |
my_Q1 = Label(root, text=score, font="Times_New_Roman, 40") | |
my_Q1.grid(row=0, column=0) | |
# creating quechange function | |
def quechange(question_number): | |
global next_button | |
global my_Q1 | |
my_Q1.grid_forget() | |
my_Q1 = Label(text=q_list[question_number - 1]) | |
next_button = Button(root, text="next".upper(), anchor=E, command=lambda: quechange(question_number + 1)) | |
next_button.grid(row=5, column=0, sticky=E, padx=5, pady=5) | |
my_Q1.grid(row=0, column=0) | |
if question_number == 5: | |
next_button.grid_forget() | |
submit_button = Button(root, text="SUBMIT", anchor=E, command=lambda: submit()) | |
submit_button.grid(row=5, column=0, sticky=E, padx=5, pady=5) | |
# creating next button | |
next_button = Button(root, text="next".upper(), anchor=E, command=lambda: quechange(2)) | |
submit_button = Button(root, text="SUBMIT", anchor=E, command=lambda: submit()) | |
next_button.grid(row=5, column=0, sticky=E, padx=5, pady=5) | |
# looping the window | |
root.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment