728x90
반응형
from tkinter import *
from tkinter import messagebox
import numpy as np
def donothing():
filewin = Toplevel(root)
button = Button(filewin, text="Do nothing button")
button.pack()
root = Tk()
root.title("연습")
root.geometry("640x400+100+100")
root.resizable(False, False)
menubar = Menu(root)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="New", command=donothing)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=root.quit)
menubar.add_cascade(label="상단메뉴1", menu=filemenu)
editmenu = Menu(menubar, tearoff=0)
editmenu.add_command(label="Undo", command=donothing)
editmenu.add_separator()
editmenu.add_command(label="Cut", command=donothing)
menubar.add_cascade(label="상단메뉴2", menu=editmenu)
helpmenu = Menu(menubar, tearoff=0)
helpmenu.add_command(label="Help Index", command=donothing)
helpmenu.add_command(label="About...", command=donothing)
menubar.add_cascade(label="상단메뉴3", menu=helpmenu)
root.config(menu=menubar)
num1 = 2
num2 = 1
def showUp():
global num1, num2
num1 = np.random.randint(9) + 1
num2 = np.random.randint(9) + 1
label.config(text=str(num1) + "x" + str(num2))
label.grid( row = 0, column = 0 )
button1.grid( row = 1, column = 0 )
button2.grid( row = 2, column = 0 )
textbox.grid( row = 3, column = 0 )
def checkUp():
global num1, num2
answer = textbox.get()
if( int(answer) == int(num1*num2) ):
messagebox.showinfo( "결과", "정답입니다.")
else:
messagebox.showinfo( "결과", "오답입니다.")
button1.grid( row = 0, column = 0 )
button2.grid( row = 1, column = 0 )
textbox.grid( row = 2, column = 0 )
textbox.delete(0, END);
root.event_generate('<<showUp>>', when='head')
label= Label(root, text="0")
button1 = Button( root, text="시작", overrelief = "solid", width = 15, command=showUp, repeatdelay=1000, repeatinterval=100)
button1.grid( row = 0, column = 0 )
button2 = Button( root, text="제출(확인)", overrelief = "solid", width = 15, command=checkUp, repeatdelay=1000, repeatinterval=100)
button2.grid( row = 1, column = 0 )
textbox = Entry( root, width=20 )
textbox.grid( row = 2, column = 0 )
root.mainloop()
아래는 초기화면입니다.
'시작' 버튼을 누르면 문제가 출제됩니다.
맨 아래칸에 '답'을 작성합니다.
'제출(확인)' 버튼을 누릅니다.
반복합니다.
만약, 답이 틀리면,
로 출력됩니다.^^
728x90
반응형
'프로그램언어(JAVA , Python)' 카테고리의 다른 글
[Python] 이진탐색( Binary Search) (0) | 2023.11.30 |
---|---|
[Python] 선형탐색( Linear Search) (0) | 2023.11.30 |
웹 통신 프로토콜... (0) | 2023.11.27 |
[javascript] 웹브라우저 자신을 닫기.( event, 호출 함수 ) (0) | 2023.11.27 |
[Python] Comprehension Expression (0) | 2023.11.22 |