如何在 Tkinter 中将对象置于 canvas 中心?
How do I center an object on the canvas in Tkinter?
我想在 Tkinter 中以 canvas 为中心画一个圆圈,但我想将 that 与 mine[=21] 的任何代码结合起来=], 没有改变太多。
我的程序:
from tkinter import *
tk = Tk()
canvas = Canvas(tk, width=1000, height=1000)
canvas.pack()
canvas.create_arc(200, 200, 100, 100, extent=359, style=ARC)
我目前使用的可以吗?
您可以像这样在 canvas 中间画圈:
from tkinter import *
tk = Tk()
canvas = Canvas(tk, width=500, height=500)
canvas.pack()
radius = 50 #set the arc radius
canvas_middle = [int(canvas['width'])/2, int(canvas['height'])/2] #find the middle of the canvas
canvas.create_arc(canvas_middle[0] - radius, canvas_middle[1] - radius, canvas_middle[0] + radius, canvas_middle[1] + radius, extent=359, style=ARC)
tk.mainloop()
我想在 Tkinter 中以 canvas 为中心画一个圆圈,但我想将 that 与 mine[=21] 的任何代码结合起来=], 没有改变太多。
我的程序:
from tkinter import *
tk = Tk()
canvas = Canvas(tk, width=1000, height=1000)
canvas.pack()
canvas.create_arc(200, 200, 100, 100, extent=359, style=ARC)
我目前使用的可以吗?
您可以像这样在 canvas 中间画圈:
from tkinter import *
tk = Tk()
canvas = Canvas(tk, width=500, height=500)
canvas.pack()
radius = 50 #set the arc radius
canvas_middle = [int(canvas['width'])/2, int(canvas['height'])/2] #find the middle of the canvas
canvas.create_arc(canvas_middle[0] - radius, canvas_middle[1] - radius, canvas_middle[0] + radius, canvas_middle[1] + radius, extent=359, style=ARC)
tk.mainloop()