当前位置: 首页>>代码示例>>Python>>正文


Python World.moveDecisions方法代码示例

本文整理汇总了Python中World.World.moveDecisions方法的典型用法代码示例。如果您正苦于以下问题:Python World.moveDecisions方法的具体用法?Python World.moveDecisions怎么用?Python World.moveDecisions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在World.World的用法示例。


在下文中一共展示了World.moveDecisions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: simpleapp_tk

# 需要导入模块: from World import World [as 别名]
# 或者: from World.World import moveDecisions [as 别名]
class simpleapp_tk(tkinter.Tk):
	def __init__(self,parent):

		
		tkinter.Tk.__init__(self,parent)
		self.parent = parent

		self.initialize()



	def initialize(self):
		#Variables and triggers
		self.runTrigger = 0
		self.world = World()
		
		self.grid()

		#Buttons
		button = tkinter.Button(self, text=u"Step", command=self.stepClick)
		button.grid(column=0, row=0, sticky = 'N')

		button = tkinter.Button(self, text=u"Auto", command=self.autoClick)
		button.grid(column=0, row=1, sticky = 'N')

		button = tkinter.Button(self, text=u"Stop", command=self.stopClick)
		button.grid(column=0, row=2, sticky = 'N')

		button = tkinter.Button(self, text=u"Reset", command=self.resetClick)
		button.grid(column=0, row=3, sticky = 'N')

		button = tkinter.Button(self, text=u"Output", command=self.outputClick)
		button.grid(column=2, row=4, sticky = 'E')

		#Label - Title
		label = tkinter.Label(self, anchor="nw", fg="black",bg="white",text="Output")
		label.grid(column=2, row=0)
		#Label - Output
		self.labelVariable = tkinter.StringVar()
		
		label = tkinter.Label(self,height="10", width = "30", textvariable=self.labelVariable,
			anchor="nw", fg="green",bg="black") 
		label.grid(column=2,row=1,rowspan=3)

		#Canvas
		self.canvas = tkinter.Canvas(width=self.world.GRID_SIZE, height=self.world.GRID_SIZE)
		self.canvas.grid(column=1,row=0,rowspan=5)
		#self.refreshCanvas()


	def stepClick(self):
		self.world.applyCurrents()
		self.world.moveDecisions()
		self.canvas.delete("all")
		for b in self.world.allBalloons:
			self.canvas.create_oval(b.getX()-self.world.COVERAGE_RADIUS,b.getY()-self.world.COVERAGE_RADIUS,b.getX()+self.world.COVERAGE_RADIUS,b.getY()+self.world.COVERAGE_RADIUS, fill="blue")
			self.canvas.create_oval(b.getX()-4,b.getY()-4,b.getX()+4,b.getY()+4, fill="red")
			self.canvas.create_line(b.getX(),b.getY(), b.getX()+b.getCurrent().getX(), b.getY()+b.getCurrent().getY(),arrow="last")
		


	def autoClick(self):
		self.runTrigger = 1
		
		while(self.runTrigger):
			self.stepClick()
			
			self.update()

		


	def stopClick(self):
		self.runTrigger = 0

	def resetClick(self):
		self.runTrigger = 0
		self.initialize()
	
	def output(self, str):
		s = '\n'
		s += str
		s += self.labelVariable.get()
		self.labelVariable.set(s)

	def outputClick(self):
		s = self.world.returnStats()
		self.output(s)
开发者ID:karithrastarson,项目名称:loon,代码行数:90,代码来源:Window.py


注:本文中的World.World.moveDecisions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。