파이썬의 Tkinter 모듈을 활용해서 간단한 메뉴 제작을 해보았다.
우선, Tkinter는 파이썬에서 사용할 수 있는 가벼운 GUI 모듈로서, 다른 툴킷에 비해 지원되는
기능도 부족하고 디자인도 너무 심플하지만 유용하게 사용이 가능하다.
I made a simple menu using Python's Tkinter module.
First of all, Tkinter is a lightweight GUI module available on Python, which lacks the functions
supported and is too simple to design but is useful.
아래는 tkinter 모듈을 활용하여 작성한 간단한 예제!
Below is a simple example created using the tkinter module!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
from tkinter import *
# 우선, Tkinter를 import하였다.(모든 모듈을 포함)
root = Tk()
# Tk 클래스 객체를 root로 생성
def Mynameis() :
print("Digirabbit")
# 아래의 버튼을 누르면 실행될 간단한 함수를 만들었다.
a = Label(root, text='My name is Program')
a.pack()
# 레이블 위젯에는 My name is Program을 작성하였고, 패킹하여 불필요한 공간을 없앴다.
b = Button(root, text='내 이름은?', command=Mynameis)
b.pack()
# 내 이름은? 이라는 버튼을 만들었고, 클릭했을 때 Mynameis 함수가 동작하도록 하였다.
c = Button(root, text='Quit', command=root.quit)
c.pack()
# Quit 종료버튼을 만들어, 클릭했을 때 quit 함수가 동작하도록 하였다.
root.mainloop()
# 이벤트 메시지 루프를 통해 키보다 또는 마우스 등 다양한 이벤트 메시지 처리가 가능하도록 한다.
|
cs |
아래와 같이, '내 이름은?' 버튼을 클릭하면 Digirabbit 메시지가 출력되며,
잘 실행되는 것을 확인할 수 있다.
As shown below, click on the 'My Name?' button to output a Digirabbit
message and check that it works well.