本文整理汇总了Python中World.nextFrame方法的典型用法代码示例。如果您正苦于以下问题:Python World.nextFrame方法的具体用法?Python World.nextFrame怎么用?Python World.nextFrame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类World
的用法示例。
在下文中一共展示了World.nextFrame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _RGB
# 需要导入模块: import World [as 别名]
# 或者: from World import nextFrame [as 别名]
#.........这里部分代码省略.........
# Place objects into window
def _initMenu(self):
self._menu.columnconfigure(0, weight=1)
self._menu.columnconfigure(1, weight=1)
stepButton = Button(self._menu, text="Step", command=self._step)
quitButton = Button(self._menu, text="Quit", command=exit)
simButton = Button(self._menu, text="Start Simulation", command=self._sim)
self._simButton = simButton
matrixLabel = Label(self._menu, text="K Matrix:")
k11 = Entry(self._menu, justify=RIGHT, textvariable=self._k11)
k12 = Entry(self._menu, justify=RIGHT, textvariable=self._k12)
k21 = Entry(self._menu, justify=RIGHT, textvariable=self._k21)
k22 = Entry(self._menu, justify=RIGHT, textvariable=self._k22)
self._k11.set("1")
self._k12.set("0")
self._k21.set("0")
self._k22.set("1")
botPositionLabel = Label(self._menu, text="Position:")
botXLabel = Label(self._menu, text="X:")
botYLabel = Label(self._menu, text="Y:")
botSizeLabel = Label(self._menu, text="Size:") #this is added for the size
bx = Entry(self._menu, justify=RIGHT, textvariable=self._bx)
by = Entry(self._menu, justify=RIGHT, textvariable=self._by)
bs = Entry(self._menu, justify=RIGHT, textvariable=self._bs) #this is added for the size
self._bx.set("0")
self._by.set("0")
self._bs.set("1") #this is added for the size
addBotButton = Button(self._menu, text="Add Bot", command=self._addBot)
lightPositionLabel = Label(self._menu, text="Position:")
lightXLabel = Label(self._menu, text="X:")
lightYLabel = Label(self._menu, text="Y:")
lx = Entry(self._menu, justify=RIGHT, textvariable=self._lx)
ly = Entry(self._menu, justify=RIGHT, textvariable=self._ly)
self._lx.set("0")
self._ly.set("0")
addLightButton = Button(self._menu, text="Add Light", command=self._addLight)
# attach objects to menu in position
stepButton.grid(row=0, column=0, sticky=N)
quitButton.grid(row=0, column=1, sticky=N)
simButton.grid(row=1, column=0, columnspan=2, sticky=N)
matrixLabel.grid(row=2, column=0, columnspan=2, sticky=N)
k11.grid(row=3, column=0, sticky=N)
k12.grid(row=3, column=1, sticky=N)
k21.grid(row=4, column=0, sticky=N)
k22.grid(row=4, column=1, sticky=N)
botPositionLabel.grid(row=5, column=0, columnspan=2, sticky=N)
botXLabel.grid(row=6, column=0, sticky=N+E)
botYLabel.grid(row=7, column=0, sticky=N+E)
botSizeLabel.grid(row=8, column=0, sticky=N+E) #this is added for the size
bx.grid(row=6, column=1, sticky=N)
by.grid(row=7, column=1, sticky=N)
bs.grid(row=8, column=1, sticky=N) #this is added for the size
addBotButton.grid(row=9, column=0, columnspan=2, sticky=N)
lightPositionLabel.grid(row=10, column=0, columnspan=2, sticky=N)
lightXLabel.grid(row=11, column=0, sticky=N+E)
lightYLabel.grid(row=12, column=0, sticky=N+E)
lx.grid(row=11, column=1, sticky=N)
ly.grid(row=12, column=1, sticky=N)
addLightButton.grid(row=13, column=0, columnspan=2, sticky=N)
# displays the window
def display(self):
self._root.mainloop()
def _step(self):
self._world.nextFrame()
def _run(self):
while self._isRunning:
self._world.nextFrame()
sleep(1.0/self._frequency)
def _sim(self):
self._isRunning = not self._isRunning
if self._isRunning:
thread = Thread(target=self._run)
thread.daemon = True
thread.start()
self._simButton["text"] = "Stop Simulation"
else:
self._simButton["text"] = "Start Simulation"
def _addBot(self):
b = Bot(self._canvas, self._bx.get(), self._by.get(), sF = self._bs.get())
k11 = self._k11.get()
k12 = self._k12.get()
k21 = self._k21.get()
k22 = self._k22.get()
b.setMatrix(k11,k12,k21,k22)
self._world.addBot(b)
def _addLight(self):
l = Light(self._canvas, self._lx.get(), self._ly.get())
self._world.addLight(l)