-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path15_quiz.py
More file actions
52 lines (38 loc) · 1.37 KB
/
15_quiz.py
File metadata and controls
52 lines (38 loc) · 1.37 KB
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
45
46
47
48
49
50
51
52
from tkinter import *
import os
root = Tk()
root.title("제목 없음 - Windows 메모장")
root.geometry("640x480") # 가로 * 세로
#root.geometry("640x480+300+100") # 가로 * 세로 + x좌표 + y좌표
root.resizable(True, True) # x(너비), y(높이) 값 변경 불가 (창 크기 변경 불가)
# 파일 입출력
filename = "mynote.txt"
def open_file():
if os.path.isfile(filename):
with open(filename, "r", encoding="utf8") as file:
txt.delete("1.0", END)
txt.insert(END, file.read())
def save_file():
with open(filename, "w", encoding="UTF8") as file:
file.write(txt.get("1.0", END))
# 메뉴 관리부분
menu = Menu(root)
menu_file = Menu(menu, tearoff=0)
menu_file.add_command(label="열기", command=open_file)
menu_file.add_command(label="저장", command=save_file)
menu_file.add_separator()
menu_file.add_command(label="끝내기", command=root.quit)
menu.add_cascade(label="파일", menu=menu_file)
menu.add_cascade(label="편집")
menu.add_cascade(label="서식")
menu.add_cascade(label="보기")
menu.add_cascade(label="도움말")
root.config(menu=menu)
# 스크롤바 관리 부분
scrollbar = Scrollbar(root)
scrollbar.pack(side="right", fill="y")
# 텍스트 관리 부분
txt = Text(root, yscrollcommand=scrollbar.set)
txt.pack(side="left", fill="both", expand=True)
scrollbar.config(command=txt.yview)
root.mainloop()