[Python] 영단어 프로그램 만들기(윈도 프로그램) - Kyeom
2022. 10. 25. 22:11ㆍPython/문제풀이
728x90
오늘은 윈도 프로그래밍에서 배운 내용으로 아주 귀여운 단어장을 만들어 볼 예정이다.
1
2
3
4
5
|
from tkinter import*
window = Tk()
window.mainloop()
|
cs |

우선 1행처럼 tkinter모듈을 불러와야한다.
기본적으로 위 코드를 이용해서 오른쪽 그림과 같은 창을 표시할 수 있다.
window.title() 을 이용해서 프로그램 이름을 바꿀 수 있다.Lavel은 문자 표현 >>> Lavel(부모윈도, 옵션) 형식레이블 같은 위젯들은 pack() 함수를 호출해야된다!
코드
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
from tkinter import*
def myFunc():
if var.get() == 1:
label1.configure(text = "중독자", font=("", 20))
elif var.get() ==2:
label1.configure(text = "헌신하다", font=("", 20))
elif var.get() ==3:
label1.configure(text = "예측하다", font=("", 20))
elif var.get() ==4:
label1.configure(text = "모순되다", font=("", 20))
elif var.get() ==5:
label1.configure(text = "일화, 비화, 진술", font=("", 20))
elif var.get() ==6:
label1.configure(text = "해독제", font=("", 20))
elif var.get() ==7:
label1.configure(text = "적절한", font=("", 20))
window = Tk()
window.title("영어 단어장")
var=IntVar()
rb1 = Radiobutton(window, text="addict", variable= var, value=1, command= myFunc, width=50,height=5, font=("", 10))
rb2 = Radiobutton(window, text="dedicate", variable= var, value=2, command= myFunc, width=50,height=5, font=("", 10))
rb3 = Radiobutton(window, text="predict", variable= var, value=3, command= myFunc, width=50,height=5, font=("", 10))
rb4 = Radiobutton(window, text="conteradict", variable= var, value=4, command= myFunc, width=50,height=5, font=("", 10))
rb5 = Radiobutton(window, text="anecdote", variable= var, value=5, command= myFunc, width=50,height=5, font=("", 10))
rb6 = Radiobutton(window, text="antidote", variable= var, value=6, command= myFunc, width=50,height=5, font=("", 10))
rb7 = Radiobutton(window, text="adequate", variable= var, value=7, command= myFunc, width=50,height=5, font=("", 10))
button1 = Button(window, text="종료", command=quit)
label1= Label(window, text="선택한 단어 : ", fg="blue", font=("", 20))
rb1.pack()
rb2.pack()
rb3.pack()
rb4.pack()
rb5.pack()
rb6.pack()
rb7.pack()
label1.pack()
button1.pack()
window.mainloop()
|
cs |
결과
사실 특별한 기능은 없다.
윈도창을 띄우고, 단어를 클릭하면 뜻이 나오고, 종료버튼까지
총 3가지가 전부다.😅
728x90
'Python > 문제풀이' 카테고리의 다른 글
[Python] 암호화 하기 - Kyeom (0) | 2022.10.26 |
---|---|
[Python] 날짜 세기 및 요일 구하기 - Kyeom (0) | 2022.10.24 |
[Python] 문자와 숫자가 섞인 데이터 정렬하기 - Kyeom (0) | 2022.10.21 |
[Python]로또 프로그램 만들기 - Kyeom (0) | 2022.10.20 |
[Python] '딕셔너리'를 활용한 음식 궁합 찾아보기 - Kyeom (0) | 2022.10.15 |