Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 特金特:我怎样才能确定顶级球员的位置?_Python_Python 3.x_Tkinter - Fatal编程技术网

Python 特金特:我怎样才能确定顶级球员的位置?

Python 特金特:我怎样才能确定顶级球员的位置?,python,python-3.x,tkinter,Python,Python 3.x,Tkinter,标题说明了这一切,我有一段代码,我想将顶层移到它原来的位置 为此,我需要获取窗口的当前位置,然后使用root.geometry('+x+y')设置新位置。如何找到顶层的当前位置?您可以通过和方法获取窗口的位置 下面是一个简单的脚本来演示*: from tkinter import Tk, Button root = Tk() def click(): print(root.winfo_x(), root.winfo_y()) Button(text="Get position", com

标题说明了这一切,我有一段代码,我想将顶层移到它原来的位置


为此,我需要获取窗口的当前位置,然后使用
root.geometry('+x+y')
设置新位置。如何找到顶层的当前位置?

您可以通过和方法获取窗口的位置

下面是一个简单的脚本来演示*:

from tkinter import Tk, Button
root = Tk()
def click():
    print(root.winfo_x(), root.winfo_y())
Button(text="Get position", command=click).grid()
root.mainloop()

*注意:为了简单起见,我在这里使用了
Tk
窗口,而不是
top-level
。但是,同样的原则也适用于
顶层