本文整理汇总了Python中Window.after方法的典型用法代码示例。如果您正苦于以下问题:Python Window.after方法的具体用法?Python Window.after怎么用?Python Window.after使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Window
的用法示例。
在下文中一共展示了Window.after方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import Window [as 别名]
# 或者: from Window import after [as 别名]
class SolarSystem:
"""
Defines the speed of the simulation
"""
SPEED = 1;
"""
Function:
Initialisation.
Description:
This initialises the solar system class by creating all of the arguments
and adding them to a list.
Args:
self: Self from class.
"""
def __init__(self):
self.__window = Window()
self.__planets = self.createPlanetList()
self.animate()
self.__window.mainLoop()
"""
Function:
createPlanetList
Description:
This creates a list of all of the planets and then appends them to
an array
Args:
self: Self from class.
Returns:
planets: A list of the planets.
"""
def createPlanetList(self):
sun = Planet(self.__window, "Sun", 330000, 0, 0, 5, "yellow", 0, 0, 0)
mercury = Planet(self.__window, "Mercury", 0.06, 0.387, 0, 5, "grey", 0.3871, 0.2056, 87.969)
venus = Planet(self.__window, "Venus", 0.82, 0.723, 0, 5, "orange", 0.7233, 0.0068, 224.701)
earth = Planet(self.__window, "Earth", 1, 1, 0, 5, "blue", 1.000, 0.0167, 365.256)
mars = Planet(self.__window, "Mars", 0.11, 1.524, 0, 5, "gold2", 1.5273, 0.0934, 686.98)
jupiter = Planet(self.__window, "Jupiter", 317.8, 5.203, 0, 5, "thistle4", 5.2028, 0.0484, 4329.63)
saturn = Planet(self.__window, "Saturn", 95.2, 9.582, 0, 5, "khaki2", 9.5388, 0.0542, 10751.805)
uranus = Planet(self.__window, "Uranus", 14.6, 19.201, 0, 5, "skyblue", 19.1914, 0.0472, 30664.015)
neptune = Planet(self.__window, "Neptune", 17.2, 30.047, 0, 5, "royalblue3", 30.0611, 0.0086, 60148.35)
planets = []
planets.append(sun)
planets.append(mercury)
planets.append(venus)
planets.append(earth)
planets.append(mars)
planets.append(jupiter)
planets.append(saturn)
planets.append(uranus)
planets.append(neptune)
return planets
"""
Function:
animate
Description:
This is used to run the actual animation of the solar system.
Every iteration it clears the screen and then draws each of the
planets.
Args:
self: Self from class.
"""
def animate(self):
self.__window.clear()
for planet in self.__planets:
planet.animate()
self.__window.after(self.SPEED, self.animate)