gpt4 book ai didi

python - 无法在 python 中的 tkinter arc 中填充颜色。

转载 作者:行者123 更新时间:2023-12-01 02:51:21 25 4
gpt4 key购买 nike

代码:-

from tkinter import *
import sys
import time
import random
root = Tk()
canvas = Canvas(root,height=700,width=700,bg='pink')
canvas.pack()
canvas.create_rectangle(0,0,10,700,fill='blue')
canvas.create_rectangle(690,0,700,700,fill='blue')
canvas.create_rectangle(0,0,700,10,fill='blue')
canvas.create_rectangle(0,690,700,700,fill='blue')
canvas.create_arc(110,9,130,29,extent=359,fill='black',style=ARC)
canvas.create_rectangle(290,500,410,510,fill='red')
root.mainloop()

一切看起来颜色都很好,只有弧线没有被填满。如何给圆弧着色?

最佳答案

根据the documentation ,除非其样式为 PIESLICECHORD,否则无法填充圆弧。

这实际上是有道理的:如何填充未闭合的几何对象?

您只需删除 style 属性即可。

canvas.create_arc(110, 9, 130, 29, extent=359, fill='black')

关于python - 无法在 python 中的 tkinter arc 中填充颜色。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44730866/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com