[英]tkinter How I can set position of label using pack()
how I can set position of label using.pack()?如何使用.pack()设置 label 的 position?
I want make something such this:我想做这样的事情:
Label(root, text ="Text").pack(x=100, y=100)
.pack()
method does not set position for any tkinter object, use .grid()
with the arguments bieng (row=,column=
). .pack()
method does not set position for any tkinter object, use .grid()
with the arguments bieng (row=,column=
). this will help you set the position of an object这将帮助您设置 object 的 position
pack() is only designed to organize geometry vertically. pack() 仅用于垂直组织几何图形。 It looks like you're looking for grid() and/or setting object sizes carefully when making the objects.
看起来您正在寻找 grid() 和/或在制作对象时仔细设置 object 大小。 If you're dead-set on using pack(), you can pack a frame and grid objects within it.
如果您不喜欢使用 pack(),您可以在其中打包一个框架和网格对象。
you can it with side=left/right/bottom/top
but in some situation you need to change your widets positon or you can use before or after
in the pack-manager
.您可以使用
side=left/right/bottom/top
来实现,但在某些情况下,您需要更改宽度位置,或者您可以在pack-manager
before or after
使用。 in some situations, the place-manager
is maybe better, if you want specific postions在某些情况下,
place-manager
可能会更好,如果您想要特定的职位
from tkinter import *
root = Tk()
root.geometry("700x700")
frame1 = Frame(root, bg="blue")
frame1.pack(fill="x", pady=20, ipady=20) # fill = x, y or "both" // pady = down from the titlebar // ipady or ipadx =
# = the height of a widget
frame2 = Frame(root, bg="red")
frame2.pack(side="left", fill="y", ipadx=20) # side = left, top, bottom, right // there also an expand function, that you can
# use it with expand=true/false, expand="yes"/"no" etc....
mainloop()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.