# Tkinter
###### tags: `Python`, `GUI`, `TK`, `tkinter`
## Hello World

```python=
import tkinter as tk
# Create a basic window
app=tk.Tk()
app.title("This is title")
app.geometry('400x300+100+300') # Initial Position of window: (width, height, x, )
# Add Label
label=tk.Label(app,
text="Hello World!",
bg="green",
font=('Arial',12),
width=15,
height=2)
label.pack()# Packer is a Geometry Manager
# Start the application
app.mainloop()
```
## Layout:
1. [Reference](https://www.delftstack.com/zh-tw/tutorial/tkinter-tutorial/tkinter-geometry-managers/)
2. Grid
a. 使用row,column來決定位置
b. Note: ``sticky=N,S,W,E`` 代表置上、下、左、右
3. Place
a. 用絕對座標來決定位置
4. Pack:
a. 用相對座標來決定位置
b. 分``side=top,bottom,left 和 right``
c. 元件可以自動填滿視窗(配合外部視窗縮放)``fill=true``
d. 元件可以自動展開自己(配合內部元素大小)``expand=true``
e. Margin: ``Inner: ipadx,ipady Outer: padx,pady``
{"metaMigratedAt":"2023-06-15T19:42:42.915Z","metaMigratedFrom":"Content","title":"Tkinter","breaks":true,"contributors":"[{\"id\":\"0a228cae-e71b-43a3-a119-15315482b72e\",\"add\":1022,\"del\":91}]"}
Tkinter
tags: Python
, GUI
, TK
, tkinter
Hello World
Layout: