Python3 Tkinter-Place

1.绝对坐标

from tkinter import *

root=Tk()
lb=Label(root,text='hello Place')
lb.place(x=0,y=0,anchor=NW)

root.mainloop()
图片.png

2.相对坐标

from tkinter import *

root=Tk()
lb=Label(root,text='hello Place')
lb.place(relx=0.5,rely=0.5,anchor=CENTER)

root.mainloop()
图片.png

3.用in来指定放置的容器

from tkinter import *

root=Tk()
bt1=Button(root,text='hello Place',fg='red')
lb=Label(root,text='hello Place',bg='green')
lb.place(relx=0.5,rely=0.5,anchor=CENTER)
bt2=Button(root,text='button in root',fg='yellow')
bt2.place(anchor=W)
bt1.place(in_=lb,anchor=W)

root.mainloop()
图片.png

4.绑定事件

bind

你可能感兴趣的:(Python3 Tkinter-Place)