寻找能够在Python tkinter画布上创建旋转椭圆(椭圆形)的Python代码,我在网上找到了一个解决方案,但代码的最后几行:
dict = {}
dict['outline'] = 'black'
dict['fill'] = 'yellow'
dict['smooth'] = 'true'
# use a polygon to draw an oval rotated 30 degrees anti-clockwise
apply(canvas.create_polygon, tuple(poly_oval(40,40, 200,300, rotation=30)), dict)
当我在Python 3.11中运行它时(代码是2000年的),出现了错误:
apply(canvas.create_polygon, tuple(poly_oval(40,40, 200,300, rotation=30)), dict)
^^^^^
NameError: name 'apply' is not defined
给出错误的代码行是做什么的?如何重写它以使它运行时没有错误?
完整代码可在线获取here。
1条答案
按热度按时间dnph8jn41#
apply()
函数可以在2000年第三版的《Tcl and Tk实用编程》中找到,但是要得到旋转椭圆,你根本不需要它。所以如果你改变:致:
它会画出一个漂亮的旋转椭圆
为了完整起见,下面的整个代码: