Python Tkinter画布绘制半圆

时间:2019-02-11 22:36:44

标签: python tkinter

乍一看似乎如此明显,以至于我从没想过要怎么做-如何绘制半圆? 我尝试使用和弦:

canvas.create_arc(x1, y1, x2, y2, style="chord",...)

但是我想不出坐标的组合。所以我尝试使用圆弧:

canvas.create_arc(x1, y1, x2, y2, style="arc",...)

这也行不通-派丽丝也不行。

总而言之,如何使用tkinter制作半圆? (就像在canvas.create中一样)

1 个答案:

答案 0 :(得分:1)

您可以创建带有圆弧的半圆。除了坐标之外,您还需要给出startextent

程度 = 学位

指定圆弧所占据的角度范围的大小。弧的范围从 start 选项指定的起始角度沿逆时针方向扩展了度数。 Degrees 可能为负。如果它大于360或小于-360,则将模数360用作范围。

开始 = 学位

指定弧所占据的角度范围的起点。 Degrees (度)是从3点钟位置逆时针测量的度数单位;它可以是正数或负数。

这是一个例子:

import tkinter as tk
from tkinter import ttk

root = tk.Tk()
canvas = tk.Canvas(root, width=300, height=200)
canvas.pack(fill="both", expand=True)

canvas.create_arc(100, 100, 200, 200, start=20, extent=180, fill="red")

root.mainloop()

enter image description here

相关问题