此幾何管理器通過將小部件放置在父小部件中的特定位置來組織小部件。
用法
widget.place( place_options )
以下是可能的選項列表 -
anchor- 小部件的確切位置 其他選項參考:可能是 N、E、S、W、NE、NW、SE 或 SW,指示小部件角落和側麵的指南針方向;默認為 NW(小部件的左上角)
bordermode- INSIDE(默認)表示其他選項引用父級的內部(忽略父級的邊框);否則外麵。
height, width- 以像素為單位的高度和寬度。
relheight, relwidth- 高度和寬度作為 0.0 和 1.0 之間的浮點數,作為父小部件高度和寬度的一部分。
relx, rely- 水平和垂直偏移作為 0.0 和 1.0 之間的浮點數,作為父小部件的高度和寬度的一部分。
x, y- 以像素為單位的水平和垂直偏移。
示例
通過在不同按鈕上移動光標來嘗試以下示例 -
# !/usr/bin/python3
from tkinter import *
top = Tk()
L1 = Label(top, text = "Physics")
L1.place(x = 10,y = 10)
E1 = Entry(top, bd = 5)
E1.place(x = 60,y = 10)
L2 = Label(top,text = "Maths")
L2.place(x = 10,y = 50)
E2 = Entry(top,bd = 5)
E2.place(x = 60,y = 50)
L3 = Label(top,text = "Total")
L3.place(x = 10,y = 150)
E3 = Entry(top,bd = 5)
E3.place(x = 60,y = 150)
B = Button(top, text = "Add")
B.place(x = 100, y = 100)
top.geometry("250x250+10+10")
top.mainloop()
執行上述代碼時,會產生以下結果 -

相關用法
- Python 3 Tkinter pack()用法及代碼示例
- Python 3 Tuple tuple()用法及代碼示例
- Python 3 Tuple len()用法及代碼示例
- Python 3 Tuple cmp()用法及代碼示例
- Python 3 Tuple max()用法及代碼示例
- Python 3 Tuple min()用法及代碼示例
- Python 3 Number tan()用法及代碼示例
- Python 3 os.fstatvfs()用法及代碼示例
- Python 3 List pop()用法及代碼示例
- Python 3 os.minor()用法及代碼示例
- Python 3 dictionary cmp()用法及代碼示例
- Python 3 String isupper()用法及代碼示例
- Python 3 os.close()用法及代碼示例
- Python 3 List index()用法及代碼示例
- Python 3 String decode()用法及代碼示例
- Python 3 os.unlink()用法及代碼示例
- Python 3 os.major()用法及代碼示例
- Python 3 Number atan()用法及代碼示例
- Python 3 List len()用法及代碼示例
- Python 3 String maketrans()用法及代碼示例
注:本文由純淨天空篩選整理自 Python 3 - Tkinter place() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。