[PYTHON] Jakushi aptitude test game

Reason for creation

This is because I was addicted to mahjong when I couldn't go out and had time to spare, and wanted to make something related to mahjong. Determining the content of the assignment At that time, something I was concerned about happened.


Referenced book

Image used


What was actually created ↓

コメント 2020-07-04 121856.png


Reflection and code

kadai.py


import tkinter as tk

Kekkahhapyou = [
"  ; ;I think you should stop not only mahjong but also other gambling.",
"  ; ;Not suitable for sparrows at all.",
"  ; ;Please refrain from mahjong. Not suitable for sparrows.",
"^^ Good! I think he has the qualities of a sparrow.",
"I have enough qualities. Why don't you try mahjong?",
"Maybe he was born to play mahjong.",
"You are a sparrow It is useless to hide it.",
"You are sure to be talented not only in mahjong but also in other gambling.",
]
def click_btn():
    pts = 0
    for i in range(7):
        if bvar[i].get() == True:
            pts = pts + 1
    tekiseiritu = int(100*pts/7)
    text.delete("1.0", tk.END)
    text.insert("1.0", "<Diagnosis>Your sparrow suitability rate" + str(tekiseiritu) + "%is." + Kekkahhapyou[pts])

root = tk.Tk()
root.title("Sparrow Diagnostic App")
root.resizable(False, False)
canvas = tk.Canvas(root, width=800, height=600)
canvas.pack()
gazou = tk.PhotoImage(file="kadai.png ")
canvas.create_image(400, 300, image=gazou)
button = tk.Button(text="Diagnosis", font=("Times New Roman", 32), bg="gray", command=click_btn)
button.place(x=400, y=480)
text = tk.Text(width=40, height=5, font=("Times New Roman", 16))
text.place(x=320, y=30)

bvar = [None]*7
cbtn = [None]*7
ITEM = [
"I like gambling",
"I think I'm lucky",
"I'm the type who is strong in production",
"I am confident in my concentration",
"I'm good at reading the other person's thoughts",
"I want to do things carefully without being impatient",
"I hate to lose",
]
for i in range(7):
    bvar[i] = tk.BooleanVar()
    bvar[i].set(False)
    cbtn[i] = tk.Checkbutton(text=ITEM[i], font=("Times New Roman", 12), variable=bvar[i], bg="#dfe")
    cbtn[i].place(x=400, y=160+40*i)
root.mainloop()

Recommended Posts

Jakushi aptitude test game
test
Load test of smartphone game app Iroha