當前位置: 首頁>>代碼示例>>Python>>正文


Python Window.clear方法代碼示例

本文整理匯總了Python中Window.clear方法的典型用法代碼示例。如果您正苦於以下問題:Python Window.clear方法的具體用法?Python Window.clear怎麽用?Python Window.clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Window的用法示例。


在下文中一共展示了Window.clear方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: SFTaxiTest

# 需要導入模塊: import Window [as 別名]
# 或者: from Window import clear [as 別名]
def SFTaxiTest(polies,verts):
	sfTaxiShader= SFTaxiShader([poly.centroid for poly in polies])
	window= Window()
	mouseCursor= MouseCursor(window)

	sfObjects= SFObjects(polies,verts)

	clickPos=None ; clock = sf.Clock()
	while window.is_open:
		tDelta= clock.restart().seconds

		sfObjects.setScale(window.view.size.x/window.size.x)

		window.clear()
		#window.draw(sfTaxiShader)
		sfTaxiShader.quad.align(window)
		sfObjects.quadCorners = sfTaxiShader.quad.corners()
		sfObjects.updateRays(sfTaxiShader.corners())
		window.draw(sfObjects)
		window.draw(mouseCursor)
		window.display()

		checkNavKeys(window,tDelta,mouseCursor.pos)
		for event in window.events:
			if		type(event) is sf.CloseEvent:			window.close()
			elif	type(event) is sf.MouseButtonEvent and event.pressed:
				if event.button==sf.Mouse.LEFT:			sfObjects.clickedAt(mouseCursor.pos)
				else:	checkForNavEvents(window,event,mouseCursor.pos)
			elif	type(event) is sf.KeyEvent and event.pressed:
				if		event.code == sf.Keyboard.ESCAPE: window.close()
				elif	event.code == sf.Keyboard.P:	sfObjects.clickedAt= selectPoly
				elif	event.code == sf.Keyboard.I:	sfObjects.clickedAt= selectIntersect
				else:	checkForNavEvents(window,event,mouseCursor.pos)
			else:	checkForNavEvents(window,event,mouseCursor.pos)
開發者ID:bobbysoon,項目名稱:TaxiVoronoi,代碼行數:36,代碼來源:__init__.py

示例2: __init__

# 需要導入模塊: import Window [as 別名]
# 或者: from Window import clear [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)
開發者ID:JamesCollerton,項目名稱:Python_Solar_System,代碼行數:86,代碼來源:SolarSystem.py


注:本文中的Window.clear方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。