Skip to main content
 首页 » 编程设计

Python 图形库 : How to set the x and y coordinates of the window

2024年10月24日12Free-Thinker

目前,我正在使用 graphics.py ,一个基于 Tkinter 的简单图形库:

我可以创建一个图形窗口:

from graphics import GraphWin  
 
winmap2 = GraphWin("Details", 200, 200) 
winmap2.setBackground("Black") 

如何设置窗口在屏幕上的 x、y 坐标?

请您参考如下方法:

GraphWin 实际上是一个 tkinter Canvas。 因此,您可以使用与 How to specify where a Tkinter window opens?

from graphics import GraphWin 
 
winmap2 = GraphWin("Details", 200, 200) 
winmap2.setBackground("Black") 
 
x = 200 
y = 100 
winmap2.master.geometry('%dx%d+%d+%d' % (200, 200, x, y)) 
winmap2.mainloop()