Python中的Tkinter的 side ipadx expand

# -*- coding:utf-8 -*-

#  side 参数  :可以垂直或者水平配置控件
"""
TOP 默认排序 从上到下
BOTTOM 由下往上排列
LEFT  由左往右排列
RIGHT 由右向左排列


"""
from tkinter import  *

window=Tk()
window.title("Hello,My world")


lab1=Label(window,text="明志科技大学",bg="lightyellow")
lab2=Label(window,text="长庚大学",bg="lightgreen")
lab3=Label(window,text="长庚科技大学",bg="lightblue")
"""
lab1.pack()
lab2.pack(side=LEFT)
lab3.pack(side=RIGHT)

#padx,pady 参数设定控件边界与容器(可想象成窗口边界)的距离或是控件边界间的距离、
lab1.pack(fill=X,pady=10)
lab2.pack(pady=10)
lab3.pack(fill=X)

"""


#ipadx:   参数可以控制标签文字与标签容器的X轴间距,ipady 参数可以控制标签文字与标签容器的y轴间距。


lab1.pack()
lab2.pack(ipadx=10000)
lab3.pack()

window.mainloop()

#-*- conding:utf-8 -*-

from tkinter import *


root =Tk()
root.title("I am a leader")
root.geometry("300x400")
oklabel=Label(root,text="OK",font="Times 20 bold",fg="white",bg="blue")
oklabel.pack(anchor=S,side=RIGHT,padx=10,pady=10)
nolabel=Label(root,text="NO",font="Times 20 bold",fg="white",bg="blue")
nolabel.pack(anchor=S,side=RIGHT,padx=10,pady=10)
root.mainloop()

#-*- coding:utf-8 -*-
from tkinter import  *

window=Tk()
window.title("Hello,My world")


lab1=Label(window,text="明志科技大学",bg="lightyellow")
lab2=Label(window,text="长庚大学",bg="lightgreen")
lab3=Label(window,text="长庚科技大学",bg="lightblue")


lab1.pack(side=LEFT,fill=Y)
lab2.pack(fill=X)
lab3.pack(fill=BOTH,expand=True)
window.mainloop()

# side fill expand 参数是互相影响的的

你可能感兴趣的:(tkinter)