如何让tkinter对象在circop路径中移动?

时间:2017-01-03 20:21:34

标签: python tkinter

我正在尝试使用tkinter制作太阳能系统。问题在于我不能让行星在太阳周围的圆形(或椭圆形)路径上移动。有任何想法吗?

1 个答案:

答案 0 :(得分:1)

使用sinuscosinus计算行星位置取决于angledistance <{1}}

sun

并使用x = sun_x - distance * math.sin(math.radians(angle)) y = sun_y - distance * math.cos(math.radians(angle)) 执行将改变角度并计算新位置的函数。

工作示例中心位于root.after(milliseconds, function_name)sun移动earthsun移动moon

earth

enter image description here

GitHub:furas/python-examples/tkinter/canvas-solar-system

相关问题