meta data for this page
차이
문서의 선택한 두 판 사이의 차이를 보여줍니다.
다음 판 | 이전 판 | ||
python:tkinter [2013/09/20 17:28] moonrepeat 새로 만듦 |
python:tkinter [2021/03/10 21:42] (현재) |
||
---|---|---|---|
줄 1: | 줄 1: | ||
- | ====== Tkinter ====== | + | ====== Python Tkinter ====== |
===== Library 사용 ===== | ===== Library 사용 ===== | ||
<code>import Tkinter</code> | <code>import Tkinter</code> | ||
또는 | 또는 | ||
<code>from Tkinter import *</code> | <code>from Tkinter import *</code> | ||
+ | |||
+ | ===== Simple Sample ===== | ||
+ | <code> | ||
+ | import Tkinter | ||
+ | |||
+ | root = Tk() | ||
+ | |||
+ | w = Label(root, text='Hello World') | ||
+ | w.pack() | ||
+ | |||
+ | root.mainloop() | ||
+ | </code> | ||
+ | ===== 푸시 단추 출력하기 ===== | ||
+ | <code> | ||
+ | import Tkinter | ||
+ | |||
+ | class App: | ||
+ | def __init__(self, master): | ||
+ | frame = Frame(master) | ||
+ | | ||
+ | frame.pack() | ||
+ | self.button = Button(frame, text="QUIT", fg="red", command=frame.quit) | ||
+ | | ||
+ | self.button.pack(side=LEFT) | ||
+ | self.w = Button(frame, text="Hello", command=self.say_hi | ||
+ | | ||
+ | self.w.pack() | ||
+ | | ||
+ | def say_hi(self): | ||
+ | print "hi there, everyone!" | ||
+ | |||
+ | root = Tk() | ||
+ | app = App(root) | ||
+ | root.mainloop() | ||
+ | |||
+ | </code> | ||
+ | |||
+ | {{tag>Python}} |