import sys
import tkinter as tk
from PIL import Image
from io import BytesIO
from tkinter import ttk
import time
import random
import tkinter.font
import webbrowser
import numpy as np
import tkinter.ttk as ttk
filename = "プログラムイメージ.jpg"
class Utils():
def __init__(self):
self.root=tk.Tk()
self.root.geometry("1270x720")
self.root.title("パソコン用語クイズ!")
self.ancer = []
""" canvas = tk.Canvas( bg="white", height=720, width=1270)
canvas.place(x=0, y=0)
img = tk.PhotoImage(file="プログラムイメージ.png", width=1270, height=720)
canvas.create_image(30, 30, image=img, anchor=tk.NW) """
self.lb1 = tk.Label(text="パソコン用語ゲーム",font=("MSゴシック", "53", "bold"),bg="green")
self.ran = "none"
self.url = "https://drive.google.com/file/d/1RWfw3yc1WzXq-mHoccMVCRKfZAk01vyP/view?usp=sharing"
self.qestion1 = []
self.qestion2 = []
self.qestion1.append("ipadはapple社のタブレットである。")#1
self.qestion1.append("インストールとはソフトの単純なコピーとは違う")#2
self.qestion1.append("Wikipediaとは有料のネット百科事典である。")#3
self.qestion1.append("Enterキーはキーボードのキーである。")#4
self.qestion1.append("OSとはオペレーティングシステムの省略である。")#5
self.qestion1.append("キャッシュの内容を無視する再読み込みは強制終了である。")#6
self.qestion1.append("IPSはモニターの液晶の種類である")#7
self.qestion1.append("解凍はファイルのサイズを小さくすること")#8
self.qestion1.append("MP4とは広く普及している音声データ圧縮方式")#9
self.qestion1.append("記憶域とストレージは同じ意味である。")#10
self.qestion1.append("コードレスとは電源コードが不要になった機器である。")#11
self.qestion1.append("CPUはグラフィックボードの省略である。")#12
self.qestion1.append("最小化とはウインドウを非表示にすること")#13
self.qestion1.append("起動中のアプリを管理するツールはデバイスマネージャーである。")#14
self.qestion1.append("TwitterはSNSの一つである。")#
self.qestion1.append("5Gとは5th Generation(第5世代)」の略ある。")#15
self.qestion1.append(" モニターとディスプレイは違う意味である。")#16
self.qestion1.append(" WQHDの解像度は1920x1080である。")#17
self.qestion1.append(" pythonは一つのプログラミング言語である。")#18
self.qestion1.append(" PowerPointはGoogleサービスの一つである。")#19
self.qestion1.append(" AMDはGPUメーカーの一つである。")#20
#記述問題
self.qestion2.append("中央演算処理装置を略してなんというでしょう?")
self.qestion2.append(" グラフィックボードを略してなんというでしょう?")
self.qestion2.append("ストレージを日本語でなんというでしょう?")
self.qestion2.append("オペレーティングシステムの略はなんでしょう?(大文字限定)")
self.qestion2.append("ウインドウを非表示にすることをなんというでしょう?")
self.qestion2.append("モニターの液晶で発色がきれいな液晶をなんという?(大文字限定)")
self.qestion2.append("Twitterは何の一つであるでしょう?")
self.qestion2.append("ハイダイナミックレンジを略してなんという?")
self.qestion2.append("ソリッドステートドライブを略してなんという?(大文字限定)")
self.qestion2.append("パーソナルコンピューターを略してなんという?(大文字限定)")
self.qestion2.append("画面上のカーソルを動かすデバイスをなんという?トラックパット✕")
self.qestion2.append("USBを増設するガジェットをなんというでしょう?")
self.qestion2.append("パソコンの映像を画面に映す機器をなんというでしょう?")
self.qestion2.append("Portable Document Formatを略してなんというでしょう?")
self.qestion2.append("MPEG-1 audio layer 3を略してなんというでしょう?")
self.qestion2.append("Portable Network Graphicsを略してなんというでしょう?")
self.qestion2.append("Joint Photographic Experts Group略してなんというでしょう?")
self.qestion2.append("MPEG-1 Audio Layer-4を略してなんというでしょう?")
self.qestion2.append("executionを略してなんというでしょう?")
self.qestion2.append("Graphics Interchange Formatを略してなんというでしょう?")
self.qestion2.append("ゲーム用のキーボードをなんというでしょう?")
self.qestion2.append("モニターを支えるアームをなんというでしょう?")
self.writea = []
self.writea.append("CPU")
self.writea.append("GPU")
self.writea.append("記憶域")
self.writea.append("OS")
self.writea.append("最小化")
self.writea.append("IPS")
self.writea.append("SNS")
self.writea.append("HDR")
self.writea.append("SSD")
self.writea.append("PC")
self.writea.append("マウス")
self.writea.append("USBハブ")
self.writea.append("モニター")
self.writea.append("PDF")
self.writea.append("MP3")
self.writea.append("PNG")
self.writea.append("JPEG")
self.writea.append("MP4")
self.writea.append("exe")
self.writea.append("gif")
self.writea.append("ゲーミングキーボード")
self.writea.append("モニターアーム")
self.ran2 = -1
self.size = 50
self.font = "MS ゴシック"
self.count = 1
self.count1 = 1
self.ran = "none"
self.run = "none"
self.retort = 0
self.answer = []
self.retort2 = 0
self.retort4 = 0
self.retort3 = 0
self.ranwrite = -1
self.sub_win1t = 0
self.sub_win2t = 0
self.answer.append("マル")#1
self.answer.append("マル")#2
self.answer.append("バツ")#3
self.answer.append("マル")#4
self.answer.append("マル")#5
self.answer.append("バツ")#6
self.answer.append("マル")#7
self.answer.append("バツ")#8
self.answer.append("マル")#9
self.answer.append("マル")#10
self.answer.append("マル")#11
self.answer.append("バツ")#12
self.answer.append("マル")#13
self.answer.append("バツ")#14
self.answer.append("マル")#15
self.answer.append("マル")#16
self.answer.append("バツ")#17
self.answer.append("バツ")#18
self.answer.append("マル")#19
self.answer.append("バツ")#20
self.answer.append("マル")#21
def maru():
self.lb12.destroy()
self.count = self.count + 1
self.count
self.maru1 = "マル"
self.lb11.destroy()
self.bt9.destroy()
self.bt10.destroy()
if self.answer[self.ran2] == self.maru1:
self.retort = self.retort + 1
self.lb7 = tk.Label(self.sub_win1,text="正解です!",font=("MSゴシック", "35", "bold"),bg="white")
self.lb7.pack()
self.bt4 = tk.Button(self.sub_win1,text="次へ",font=("MSゴシック", "70", "bold"),bg="red",command=qestion)
self.bt4.place(x=450,y=400)
else:
self.lb7 = tk.Label(self.sub_win1,text="残念不正解です。正解は×です。",font=("MSゴシック", "35", "bold"),bg="white")
self.lb7.pack()
self.bt4 = tk.Button(self.sub_win1,text="次へ",font=("MSゴシック", "70", "bold"),bg="red",command=qestion)
self.bt4.place(x=450,y=400)
def batu():
self.lb12.destroy()
self.count = self.count + 1
print(self.count + 100)
#if self.ran == self.run:
self.batu1 = "バツ"
self.lb11.destroy()
self.bt9.destroy()
self.bt10.destroy()
if self.answer[self.ran2] == self.batu1:
self.retort = self.retort + 1
self.lb7 = tk.Label(self.sub_win1,text="正解です!",font=("MSゴシック", "35", "bold"),bg="white")
self.lb7.pack()
self.bt4 = tk.Button(self.sub_win1,text="次へ",font=("MSゴシック", "70", "bold"),bg="red",command=qestion)
self.bt4.place(x=450,y=400)
else:
self.lb7 = tk.Label(self.sub_win1,text="残念不正解です。正解は〇です。",font=("MSゴシック", "35", "bold"),bg="white")
self.lb7.pack()
self.bt4 = tk.Button(self.sub_win1,text="次へ",font=("MSゴシック", "70", "bold"),bg="red",command=qestion)
self.bt4.place(x=450,y=400)
def qestion():
self.sub_win1t = 1
self.sub_win1.protocol("WM_DELETE_WINDOW", click_close)
self.ran2= self.ran2 + 1
if self.count <= 20:
self.no = str(self.count)+"/20"
self.lb12 = tk.Label(self.sub_win1,text=self.no,font=("MSゴシック", "30", "bold"),bg="white")
self.lb12.pack()
self.bt4.destroy()
self.lb7.destroy()
self.bt4.destroy()
if self.count <= 20:
self.lb11 = tk.Label(self.sub_win1,text=self.qestion1[self.ran2],font=("MSゴシック", "30", "bold"),bg="white")
self.bt10 = tk.Button(self.sub_win1,text="✕",font=("MSゴシック", "100", "bold"),bg="blue",command=batu)
self.bt9 = tk.Button(self.sub_win1,text="〇",font=("MSゴシック", "100", "bold"),bg="red",command=maru)
self.lb11.pack()
self.bt10.place(x=800,y=400)
self.bt9.place(x=200,y=400)
if self.count == 21:
self.lb12.destroy()
self.bt10.destroy()
self.bt9.destroy()
self.lb11.destroy()
self.lb11 = tk.Label(self.sub_win1,text="終了です!",font=("MSゴシック", "40", "bold"),bg="white")
self.lb11.pack()
self.retort2 = 20 - self.retort
self.lb12 = tk.Label(self.sub_win1,text="正解数"+str(self.retort)+"回",font=("MSゴシック", "30", "bold"),bg="white")
self.lb12.pack()
self.lb13 = tk.Label(self.sub_win1,text="不正解数"+str(self.retort2)+"回",font=("MSゴシック", "30", "bold"),bg="white")
self.lb13.pack()
self.bt10 = tk.Button(self.sub_win1,text="終了",font=("MSゴシック", "70", "bold"),bg="red",command=rpeat)
self.bt10.place(x=450,y=400)
def a():
self.lb12.destroy()
self.bt4.destroy()
self.s = self.textbox.get("1.0","end")
print("1")
print(self.s.replace("\n",""))
print("2")
print(self.writea[self.ranwrite])
self.textbox.destroy()
self.lb11.destroy()
#self.textbox.destroy()
if self.writea[self.ranwrite] == self.s.replace("\n",""):
self.count1 = self.count1 + 1
self.lb7 = tk.Label(self.sub_win2,text="正解です!",font=("MSゴシック", "35", "bold"),bg="white")
self.lb7.pack()
self.bt4 = tk.Button(self.sub_win2,text="次へ",font=("MSゴシック", "53", "bold"),bg="red",command=qwrite)
self.bt4.place(x=550,y=400)
self.retort3 = self.retort3 + 1
else:
self.count1 = self.count1 + 1
self.lb7 = tk.Label(self.sub_win2,text="残念不正解です。"+self.writea[self.ranwrite]+"です。",font=("MSゴシック", "35", "bold"),bg="white")
self.lb7.pack()
self.bt4 = tk.Button(self.sub_win2,text="次へ",font=("MSゴシック", "53", "bold"),bg="red",command=qwrite)
self.bt4.place(x=550,y=400)
self.retort4 = self.retort4 + 1
def qwrite():
self.sub_win2t = 1
self.sub_win2.protocol("WM_DELETE_WINDOW", click_close)
self.ran2= self.ran2 + 1
if self.count1 <= 22:
self.no1 = str(self.count1)+"/21"
self.lb12 = tk.Label(self.sub_win2,text=self.no1,font=("MSゴシック", "30", "bold"),bg="white")
self.lb12.pack()
self.bt4.destroy()
self.lb7.destroy()
self.ranwrite= self.ranwrite + 1
self.lb11 = tk.Label(self.sub_win2,text=self.qestion2[self.ranwrite],font=("MSゴシック", "30", "bold"),bg="white")
self.lb11.pack()
self.textbox = tk.Text(self.sub_win2,wrap = tk.NONE,bg="white" ,fg="red",height=1,width=30)
self.textbox.configure(font=(self.font,self.size))
#self.frame = tk.Frame(self.sub_win2, pady=20, padx=5)
#self.entry = tk.Entry(self.frame)
#self.frame.pack()
#self.entry.pack()
self.textbox.pack()
#self.textbox.place(x=140,y=200)
self.bt4=tk.Button(self.sub_win2,text="決定",font=("MSゴシック", "53", "bold"),command=a,bg="red")
self.bt4.place(x=550,y=400)
if self.count1 == 22:
self.bt4.destroy()
self.textbox.destroy()
self.lb12.destroy()
self.lb11.destroy()
self.lb20 = tk.Label(self.sub_win2,text="終了です!",font=("MSゴシック", "40", "bold"),bg="white")
self.lb20.pack()
self.lb12 = tk.Label(self.sub_win2,text="正解数"+str(self.retort3)+"回",font=("MSゴシック", "30", "bold"),bg="white")
self.lb12.pack()
self.lb13 = tk.Label(self.sub_win2,text="不正解数"+str(self.retort4)+"回",font=("MSゴシック", "30", "bold"),bg="white")
self.lb13.pack()
self.bt10 = tk.Button(self.sub_win2,text="終了",font=("MSゴシック", "70", "bold"),bg="red",command=rpeat1)
self.bt10.place(x=450,y=400)
def qiz():
self.sub_win1t = 1
self.ran= random.randint(0,20)
print(self.ran)
self.sub_win1 = tk.Toplevel()
self.sub_win1.geometry("1270x720")
self.lb7 = tk.Label(self.sub_win1,text="〇×クイズ",font=("MSゴシック", "53", "bold"),bg="green")
self.lb7.place(x=460,y=70)
print("通ったよ!")
self.bt4=tk.Button(self.sub_win1,text="スタート",font=("MSゴシック", "53", "bold"),command=qestion,bg="red")
self.bt4.place(x=450,y=400)
def write():
self.sub_win2 = tk.Toplevel()
self.sub_win2.geometry("1270x720")
self.lb7 = tk.Label(self.sub_win2,text="記述クイズ",font=("MSゴシック", "53", "bold"),bg="green")
self.lb7.place(x=460,y=70)
print("通ったよ!")
self.bt4=tk.Button(self.sub_win2,text="スタート",font=("MSゴシック", "53", "bold"),command=qwrite,bg="red")
self.bt4.place(x=450,y=400)
def words():
webbrowser.open(self.url, new=0, autoraise=True)
self.lb1.place(x=300,y=70)
self.bt2=tk.Button(self.root,text="〇×クイズ",font=("MSゴシック", "50", "bold"),command=qiz,bg="red")
self.bt2.place(x=480,y=500)
self.bt1=tk.Button(self.root,text="用語一覧",font=("MSゴシック", "50", "bold"),command=words,bg="red")
self.bt1.place(x=50,y=500)
self.bt3=tk.Button(self.root,text="記述クイズ",font=("MSゴシック", "45", "bold"),command=write,bg="red")
self.bt3.place(x=900,y=500)
def click_close():
if self.sub_win1t == 1:
self.sub_win1.destroy()
self.sub_win1t = 0
self.retort = 0
self.retort2 = 0
if self.sub_win2t == 1:
self.sub_win2.destroy()
self.sub_win2t = 0
self.retort4 = 0
self.retort3 = 0
self.count1 = 1
self.ranwrite = -1
self.count = 1
self.ran2 = -1
def rpeat():
self.sub_win1.destroy()
self.count = 1
self.ran2 = -1
self.retort = 0
self.retort2 = 0
def rpeat1():
self.lb20.destroy()
self.sub_win2.destroy()
self.retort4 = 0
self.retort3 = 0
self.count1 = 1
self.ranwrite = -1
def tkinter(self):
self.root.mainloop()
def main():
utils=Utils()
utils.tkinter()
# main関数の実行
if __name__ == "__main__":
main()