【问题标题】:Setting objects coordinates in tkinter在 tkinter 中设置对象坐标
【发布时间】:2013-11-30 19:53:21
【问题描述】:

我正在使用 tkinter,但无论如何我都找不到设置对象的坐标。在 python 文档中,只提到了使用 side 。有没有办法在窗口中说我的对象的左侧和顶部? 例如:

import tkinter
from tkinter.constants import *
tk = tkinter.Tk()
frame = tkinter.Frame(tk, relief=RIDGE, borderwidth=2)
frame.pack(fill=BOTH,expand=1)
label = tkinter.Label(frame, text="Hello, World")
label.pack(fill=X, expand=1)
button = tkinter.Button(frame,text="Exit",command=tk.destroy)#here I need to put my button at left=0,top=10 !!!
button.pack(side=BOTTOM)
tk.mainloop()

【问题讨论】:

    标签: python user-interface python-3.x tkinter


    【解决方案1】:

    使用place() 代替pack()。但不要在同一个Frame 中同时使用pack()grid()place()。当然,您可以在父级Frame 中使用(例如)pack(),在子级Frame 中使用grid()

    见:Grid Geometry ManagerPack Geometry ManagerPlace Geometry Manager

    【讨论】:

      猜你喜欢
      • 2018-11-01
      • 1970-01-01
      • 2015-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多