[파이썬 GUI 프로그래밍] 처음 시작

기초/Python 2018. 9. 10. 15:47

[파이썬 GUI 프로그래밍]


시작하는 방법


Qt4 설치



1. Tkinter 소개

Tkinter는 Tcl/Tk에 대한 파이썬 Wrapper로서 Tcl/Tk를 파이썬에 사용할 수 있도록 한 Lightweight GUI 모듈이다. Tcl은 Tool Command Language의 약자로서 일종의 프로그래밍 언어이며, Tk는 크로스 플랫폼에 사용되는 일종의 GUI 툴킷이다. Tkinter는 타 GUI 프레임워크나 툴킷에 비해 지원되는 위젯들이 부족하고 UI도 그렇게 예쁘지 않다는 단점이 있지만, Python 설치시 기본적으로 내장되어 있는 파이썬 표준 라이브러리이기 때문에 쉽고 간단한 GUI 프로그램을 만들 때 활용




기본 

1
2
3
4
5
6
7
8
9
10
11
12
from tkinter import *
 
class Window(Frame):
 
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.master = master
 
root = Tk()
app = Window(root)
root.mainloop()
 
cs


https://pythonprogramming.net/tkinter-python-3-tutorial-adding-buttons/?completed=/python-3-tkinter-basics-tutorial/







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 *
 
class Window(Frame):
 
    def __init__(self, master=None):
 
        Frame.__init__(self, master)
        self.master = master
        self.init_window()
 
    def init_window(self):
        self.master.title("GUI")
        self.pack(fill=BOTH, expand=1)
        quitButton = Button(self, text="Exit", command=self.client_exit)
        quitButton.place(x=100, y=100)

# client function
    def client_exit(self):
        exit()
 
root = Tk()
# window size
root.geometry("400x300")
app = Window(root)
root.mainloop()
cs



[실행화면]








http://pythonstudy.xyz/python/article/120-Tkinter-%EC%86%8C%EA%B0%9C




'기초 > Python' 카테고리의 다른 글

[파이썬 GUI 프로그래밍] 상단바  (0) 2018.09.11
[파이썬 기초] 입력과 출력  (0) 2018.08.14
[파이썬 기초] 객체지향, 클래스  (0) 2018.08.10
[기초] 지역변수, Global문, DocString  (0) 2018.08.08
[기초] 함수  (0) 2018.08.07

설정

트랙백

댓글