💾 Archived View for twotwos.pollux.casa › code › Affirmatron.py captured on 2022-04-29 at 11:52:59.
⬅️ Previous capture (2021-12-03)
-=-=-=-=-=-=-
import tkinter as tk from tkinter import font wimdow = tk.Tk() truefont = font.Font(family="Arial", size=13) boldfont = font.Font(family="Arial bold", size=13) wimdow.geometry("500x300") questions = [] current_question = -1 class Question: def __init__(self,question,effects): self.question = question self.effects = effects self.choice = 0 questions.append(self) lyrics = ["I believe the sun should never set upon an argument", "I believe we place our happiness in other people's hands", "I believe that junk food tastes so good because it's bad for you", "I believe your parents did the best job they knew how to do", "I believe that beauty magazines promote low self-esteem", "I believe I'm loved when I'm completely by myself alone", "I believe in Karma what you give is what you get returned", "I believe you can't appreciate real love until you've been burned", "I believe the grass is no more greener on the other side", "I believe you don't know what you've got until you say goodbye", "I believe you can't control or choose your sexuality", "I believe that trust is more important than monogamy", "I believe your most attractive features are your heart and soul", "I believe that family is worth more than money or gold", "I believe the struggle for financial freedom is unfair", "I believe the only ones who disagree are millionaires", "I believe forgiveness is the key to your unhappiness", "I believe that wedded bliss negates the need to be undressed", "I believe that God does not endorse TV evangelists", "I believe in love surviving death into eternity"] for proposition in lyrics: Question(proposition,{"Affirmation/Refutation":1}) def choose(value): global current_question global wimdow print(current_question) print(questions[current_question].question) questions[current_question].choice = value for widget in wimdow.winfo_children(): widget.destroy() wimdow.quit() #next_question() def str_agree(e): choose(1) def agree(e): choose(0.5) def neutral(e): choose(0) def disagree(e): choose(-0.5) def str_disagree(e): choose(-1) def next_question(): global current_question global current_proposition global escape current_question+=1 if current_question == len(questions): for widget in wimdow.winfo_children(): widget.destroy() wimdow.quit() wimdow.quit() wimdow.quit() wimdow.quit() escape = True return None current_proposition=questions[current_question] question = current_proposition wimdow.geometry("400x400") tktop = tk.Frame(master=wimdow,width=400,height=200) tktop.pack(fill=tk.BOTH,side=tk.TOP,expand=True) tkbottom = tk.Frame(master=wimdow,width=400,height=200) tkbottom.pack(fill=tk.BOTH,side=tk.BOTTOM,expand=True) tkquestion = tk.Label(master=tktop,text=question.question,font=truefont) tkquestion.pack(fill="none", expand=True) tkstr_agree = tk.Label(master=tkbottom,text="Strongly Agree",bg="#1b5e20",fg="white",font=truefont) tkstr_agree.bind('<ButtonRelease-1>',str_agree) tkstr_agree.pack(fill=tk.BOTH,side=tk.TOP,expand=True) tkagree = tk.Label(master=tkbottom,text="Agree",bg="#4caf50",fg="white",font=truefont) tkagree.bind('<ButtonRelease-1>',agree) tkagree.pack(fill=tk.BOTH,side=tk.TOP,expand=True) tkneutral = tk.Label(master=tkbottom,text="Neutral/Unsure",bg="#aaaaaa",fg="white",font=truefont) tkneutral.bind('<ButtonRelease-1>',neutral) tkneutral.pack(fill=tk.BOTH,side=tk.TOP,expand=True) tkdisagree = tk.Label(master=tkbottom,text="Disagree",bg="#f44336",fg="white",font=truefont) tkdisagree.bind('<ButtonRelease-1>',disagree) tkdisagree.pack(fill=tk.BOTH,side=tk.TOP,expand=True) tkstr_disagree = tk.Label(master=tkbottom,text="Strongly Disagree",bg="#b71c1c",fg="white",font=truefont) tkstr_disagree.bind('<Button-1>',str_disagree) tkstr_disagree.pack(fill=tk.BOTH,side=tk.TOP,expand=True) wimdow.mainloop() escape = False while escape == False: next_question() wimdow.quit() wimdow.quit() wimdow.quit() wimdow.quit() visualiser = {} questions = sorted(questions, key=lambda question:question.choice) extreme_responses = 0 affirmation = 0 defirmation = 0 neutrals = 0 for question in questions: if question.choice == 1: extreme_responses += 1 affirmation += 1 if question.choice == 0.5: extreme_responses += 0.5 affirmation += 0.5 if question.choice == 0: neutrals += 1 if question.choice == -0.5: extreme_responses += 0.5 defirmation += 0.5 if question.choice == -1: extreme_responses += 1 defirmation += 1 for question in questions: if question.choice == 1: e = tk.Label(master=wimdow,text=question.question,bg="#1b5e20",font=boldfont,height=2) e.pack(side=tk.BOTTOM) if question.choice == 0.5: e = tk.Label(master=wimdow,text=question.question,bg="#4caf50",font=truefont,height=1) e.pack(side=tk.BOTTOM) if question.choice == 0: e = tk.Label(master=wimdow,text=question.question,bg="#aaaaaa",font=truefont,height=1) e.pack(fill="none",side=tk.BOTTOM,expand=True) if question.choice == -0.5: e = tk.Label(master=wimdow,text=question.question,bg="#f44336",font=truefont,height=1) e.pack(side=tk.BOTTOM) if question.choice == -1: e = tk.Label(master=wimdow,text=question.question,bg="#b71c1c",font=boldfont,height=2) e.pack(side=tk.BOTTOM) wimdow.geometry("400x747") print("Extremeness: " + str(100*extreme_responses/len(questions)) + "%") print("Affirmation: " + str(100*affirmation/len(questions)) + "%") print("Refutation: " + str(100*defirmation/len(questions)) + "%") wimdow.mainloop()