Python 使用“放置几何图形管理器”移动顶层
一旦应用程序被创建并显示在屏幕上,是否可以将应用程序移动到屏幕上的其他位置 我有一个库函数,它可以像这样放置应用程序或顶层框架Python 使用“放置几何图形管理器”移动顶层,python,tkinter,Python,Tkinter,一旦应用程序被创建并显示在屏幕上,是否可以将应用程序移动到屏幕上的其他位置 我有一个库函数,它可以像这样放置应用程序或顶层框架 def create_top_window(master, node, center=True): if not master: master = TK.Toplevel() if center: center_window(master, node.width, node.height) node.widget
def create_top_window(master, node, center=True):
if not master:
master = TK.Toplevel()
if center:
center_window(master, node.width, node.height)
node.widget = TK.Frame(master, relief=node.relief)
node.widget.place(x=node.x, y=node.y,width=node.width, height=node.height)
def center_window(root, w=300, h=200): # Center main application window
# set screen width and height
ws = root.winfo_screenwidth()
hs = root.winfo_screenheight()
# calculate position x, y
x = (ws/2) - (w/2)
y = (hs/2) - (h/2)
root.geometry('%dx%d+%d+%d' % (w, h, x, y))
节点是一个对象,除了小部件所需的属性之外,它还具有其他属性,并且将包含应用程序所需的大小
我又打电话给那个地方,但没用。
如何在以后的程序中更改屏幕上的位置?
place
严格用于在其他小部件中定位小部件
要移动顶级或根窗口,可以使用命令。例如,要将窗口移动到左上角,可以执行以下操作:
root.geometry("+0+0")
place
严格用于在其他小部件中定位小部件
要移动顶级或根窗口,可以使用命令。例如,要将窗口移动到左上角,可以执行以下操作:
root.geometry("+0+0")
@jimscafe-See查看几何字符串文档。@jimscafe-See查看几何字符串文档。