本文整理汇总了Python中ui.UI.update_time_label方法的典型用法代码示例。如果您正苦于以下问题:Python UI.update_time_label方法的具体用法?Python UI.update_time_label怎么用?Python UI.update_time_label使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ui.UI
的用法示例。
在下文中一共展示了UI.update_time_label方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EdenApp
# 需要导入模块: from ui import UI [as 别名]
# 或者: from ui.UI import update_time_label [as 别名]
class EdenApp():
"""The EdenApp class is the overall app.
When it runs it creates two objects:
The simulation, that runs the actual simulation.
The ui, that presents visuals of the simulation on the screen.
"""
def __init__(self, master):
"""Create the app."""
self.master = master
# create the simulation object
utility.log_welcome()
log("> Creating simulation")
self.simulation = Simulation()
# create the app
log("> Creating UI")
master.wm_title("Eden")
self.frame = Frame(master)
self.frame.grid()
# create the ui
self.ui = UI(self.master, self, self.frame)
self.create_key_bindings()
self.running = False
self.time = 0
def create_key_bindings(self):
"""Set up key bindings."""
def leftKey(event):
self.rotate_map(-10.0)
def rightKey(event):
self.rotate_map(10.0)
def upKey(event):
self.change_time_step(1)
def downKey(event):
self.change_time_step(-1)
def spaceKey(event):
self.toggle_running()
self.master.bind('<Left>', leftKey)
self.master.bind('<Right>', rightKey)
self.master.bind('<Up>', upKey)
self.master.bind('<Down>', downKey)
self.master.bind('<space>', spaceKey)
def step(self):
"""Advance one step in time."""
self.time += settings.time_step_size
self.ui.update_time_label(self.time)
self.simulation.step()
self.ui.paint_tiles()
self.master.update()
def rotate_map(self, degrees):
"""Spin the map."""
for c in self.simulation.world.cells:
c.longitude += degrees
if c.longitude < 0:
c.longitude += 360.0
elif c.longitude >= 360.0:
c.longitude -= 360.0
self.simulation.world.cells = sorted(
self.simulation.world.cells,
key=attrgetter("latitude", "longitude"))
self.ui.paint_tiles()
def change_time_step(self, direction):
"""Change the time_step_size."""
time_steps = [
1,
10,
60,
60*10,
60*60,
60*60*6,
60*60*24,
60*60*24*7,
60*60*24*30,
60*60*24*365,
60*60*24*365*10,
60*60*24*365*50,
60*60*24*365*100,
60*60*24*365*500,
60*60*24*365*1000,
60*60*24*365*10000,
60*60*24*365*100000,
60*60*24*365*1000000
]
step_descriptions = [
"1s",
#.........这里部分代码省略.........