Shiny Lime Green Star J, [์†Œํ”„ํŠธ์›จ์–ด์™€์ฐฝ์˜์ ์‚ฌ๊ณ ] 11์ฃผ์ฐจ. ํ”„๋กœ๊ทธ๋žจ ํ™”๋ฉด ๊ตฌ์„ฑ

# GUI (Graphic User Interface)

  • ์‹œ๊ฐ์  ์š”์†Œ๋“ค๋กœ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ๊ตฌ์„ฑ
  • ํ”„๋กœ๊ทธ๋žจ์˜ ๋‹ค์–‘ํ•œ ๊ธฐ๋Šฅ์„ ๊ทธ๋ž˜ํ”ฝ์œผ๋กœ ๋‚˜ํƒ€๋‚ธ ๊ฒƒ

 

# tkinter ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ

  • ํŒŒ์ด์ฌ ํ‘œ์ค€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
  • ํŒŒ์ด์ฌ ์„ค์น˜ ์‹œ ๊ธฐ๋ณธ์ ์œผ๋กœ ๋‚ด์žฅ
  • ๊ฐ„๋‹จํ•˜๊ฒŒ GUI ํ”„๋กœ๊ทธ๋ž˜๋ฐ ๊ฐ€๋Šฅ
  • import ํ•ด์„œ ์‚ฌ์šฉ ๊ฐ€๋Šฅ

- from tkinter import *

- import tkinter *alisa๋ฅผ ์ง€์ •ํ•ด์„œ ํ™œ์šฉํ•  ์ˆ˜๋„ ์žˆ์Œ*

- import tkinter as tt

 

https://docs.python.org/ko/3/library/ ํŒŒ์ด์ฌ ํ‘œ์ค€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ฐธ๊ณ 

 

The Python Standard Library

While The Python Language Reference describes the exact syntax and semantics of the Python language, this library reference manual describes the standard library that is distributed with Python. It...

docs.python.org


 

# ๊ฐ„๋‹จํ•˜๊ฒŒ ์ฐฝ(window) ๋„์›Œ๋ณด๊ธฐ

  • windows = Tk()

  • windows.title()

- title ์ถ”๊ฐ€

  • windows.geometry()

- ํ™”๋ฉด ์œ„์น˜ ๊ฐ„๋‹จ ์ง€์ • ("์ฐฝ๋„“์ดx์ฐฝ๋†’์ด+๊ฐ€๋กœ์œ„์น˜+์„ธ๋กœ์œ„์น˜")

  • windows.resizable()

- False ใ…ก> ํฌ๊ธฐ ๊ณ ์ •


 

# ์œ„์ ฏ(Widget)

  • ํŒŒ์ด์ฌ์€ GUI ์š”์†Œ์ธ ๊ธฐ๋ณธ ์œ„์ ฏ ์ œ๊ณต
  • ๊ฐ ์œ„์ ฏ์€ ๊ฐ์ฒด ์ƒ์„ฑ ํ›„ ์†์ •์„ ์ง€์ •ํ•ด ์‚ฌ์šฉ
  • ๋ฃจํŠธ์œˆ๋„์šฐ์— ๋ถ€์ฐฉ๋ผ ๋ฐฐ์น˜ํ•ด์•ผ ์‚ฌ์šฉ ๊ฐ€๋Šฅ

https://www.tutorialspoint.com/python/python_gui_programming.htm ์„ธ๋ถ€ ๋‚ด์šฉ ์ฐธ๊ณ 


# ์œ„์ ฏ(Widget) ใ…ก ๋ผ๋ฒจ(๋˜๋Š” ๋ ˆ์ด๋ธ”)

  • Label() Object
  • label = Label(๋ถ€๋ชจ์œˆ๋„์šฐ, ์˜ต์…˜)
  • ๋‹จ์ˆœ ๋ฌธ์ž์—ด, ์ด๋ฏธ์ง€ ํ‘œ์‹œํ•  ๋•Œ ์‚ฌ์šฉ
  • ํ…์ŠคํŠธ์™€ ์ด๋ฏธ์ง€ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ๋Š” ์œ„์ ฏ

- .pack(side = LEFT) : ๊ธ€์”จ๊ฐ€ ์™ผ์ชฝ์œผ๋กœ ์น˜์šฐ์ณ์ง


# ์œ„์ ฏ(Widget) ใ…ก Label/PhotoImage

    • png, gif ๋งŒ ๊ฐ€๋Šฅ

- "C://python_code" ๊ทธ๋ฆผ ์œ„์น˜


# ์œ„์ ฏ(Widget) ใ…ก  ๋ฒ„ํŠผ

  • button = Button (๋ถ€๋ชจ์œˆ๋„์šฐ, text = "๋ฌธ์ž์—ด", ์˜ต์…˜)


# ์œ„์ ฏ(Widget) ใ…ก  ์—”ํŠธ๋ฆฌ

  • ์ž…๋ ฅ๋ฐ›๋Š” ์œ„์ ฏ, ๋‹จ์ผ ์ž…๋ ฅ์ฐฝ(Single Line Edit)
  • Entry ํด๋ž˜์Šค ์‚ฌ์šฉ


# ์œ„์ ฏ(Widget) ใ…ก  ์ฝค๋ณด๋ฐ•์Šค

  • ttk ๋ชจ๋“ˆ์„ import ํ•ด์•ผ ๋จ. from tkinter.ttk import *
  • ttk ๋ชจ๋“ˆ์˜ Combobox ํด๋ž˜์Šค ์‚ฌ์šฉ


# ์œ„์ ฏ(Widget) ใ…ก  ๋ฉ”์‹œ์ง€๋ฐ•์Šค

  • ์•Œ๋ฆผ์ฐฝ
  • ๋ฉ”์‹œ์ง€ ์—ฌ๋Ÿฌ ์ข…๋ฅ˜๊ฐ€ ์กด์žฌํ•จ (ex. ์ •๋ณดํ™•์ธ, ๊ฒฝ๊ณ  ๋“ฑ...)
  • tkinter์˜ massagebox ๋ชจ๋“ˆ ์‚ฌ์šฉ
showinfo()
showwarning()
showerror()
askquestion()
askokcancel()
askyesno()
askretrycancle()


# ์œ„์ ฏ(Widget)  ๋ฐฐ์น˜ - place()

  • ์ƒ๋Œ€, ์ ˆ๋Œ€์œ„์น˜ ํ™œ์šฉ
  • ์ ˆ๋Œ€์œ„์น˜ : ์œ„์ ฏ์ด ํ‘œ์‹œ๋  ์œ„์น˜ ์ขŒํ‘œ๋ฅผ ์ˆซ์ž๋กœ ํ‘œ๊ธฐ, place()
  • ์ƒ๋Œ€์œ„์น˜ : ์œ„์ ฏ ๊ฐ„ ์ƒ๋Œ€์œ„์น˜๋ฅผ ํ‘œ๊ธฐ, pack(), grid()
  • - pack() : window ์ค‘์•™์—์„œ ์•„๋ž˜์˜ ์ˆœ์„œ๋กœ ๋ฐฐ์น˜
  • - grid() : ๋ณ„๋„์˜ ๊ฒฉ์ž๋ฅผ ๋งŒ๋“ค์–ด ๋ฐฐ์น˜

 

windows (1).ipynb
0.01MB

user-img J
wogml
ํ˜„์žฌ๊ธ€
[์†Œํ”„ํŠธ์›จ์–ด์™€์ฐฝ์˜์ ์‚ฌ๊ณ ] 11์ฃผ์ฐจ. ํ”„๋กœ๊ทธ๋žจ ํ™”๋ฉด ๊ตฌ์„ฑ
ํ•จ๊ป˜ ๋ณด๋ฉด ์ข‹์„ ํฌ์ŠคํŠธ