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


Python Button.setHoverColor方法代码示例

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


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

示例1: compAbyNLM

# 需要导入模块: from Button import Button [as 别名]
# 或者: from Button.Button import setHoverColor [as 别名]
def compAbyNLM(DISPLAY_SURF):
	print ("INSIDE AbyNLM.py")

	btn_a1 = pygame.image.load('Images/buttons/parameters/a1.png') 	
	btn_a2 = pygame.image.load('Images/buttons/parameters/a2.png') 
	btn_a3 = pygame.image.load('Images/buttons/parameters/a3.png') 
	btn_a4 = pygame.image.load('Images/buttons/parameters/a4.png') 

	btn_back = Button('Back')
	btn_back.setColor(RED)
	btn_back.setHoverColor(LIME)
	btn_back.setFontColor(BLUE)
	clock = pygame.time.Clock()
	background=pygame.image.load('Images/game1/input_values.png')	
	run = True
	while run:
		DISPLAY_SURF.blit(background,SCREEN_TOPLEFT)
		mouse = pygame.mouse.get_pos()
		for event in pygame.event.get():
			if event.type == pygame.QUIT:
				run = False
				pygame.quit()
				sys.exit()
			elif event.type == pygame.MOUSEBUTTONDOWN:
				if rect_a1.collidepoint(mouse):
					countInputs = 1;	# countInputs is related to the y coordinate of the input text boxes
					initial_velocity = inputbox.ask(DISPLAY_SURF, "Initial velocity, u",countInputs)
					initial_velocity = float (initial_velocity)
					countInputs = countInputs + 5;
					final_velocity = inputbox.ask(DISPLAY_SURF, "Final Velocity, v",countInputs)
					final_velocity = float (final_velocity)
					countInputs = countInputs + 5;
					time = inputbox.ask(DISPLAY_SURF, "Time, t",countInputs)
					time = float (time)
					if(time < 0):
						errorScreen.errorScreen(DISPLAY_SURF,"Negative time entered")
						run = False
					if(time == 0):
						errorScreen.errorScreen(DISPLAY_SURF,"Time cannot be zero in this case")
						run = False
					acceleration = (final_velocity - initial_velocity)/time
					displacement = initial_velocity*time+ acceleration*time*time/2
					
					font = pygame.font.Font(None, 36)
					text = font.render("Acceleration hence calculated is "+ str(acceleration) +"meter/sec/sec", 1, WHITE)
					path = "Images/game1/Explanation/Calculate_A/G1/"
					anim1(DISPLAY_SURF,text,final_velocity,initial_velocity,acceleration,time,displacement,path)
					run = False
				elif rect_a2.collidepoint(mouse):
					countInputs = 1;	# countInputs is related to the y coordinate of the input text boxes
					displacement = inputbox.ask(DISPLAY_SURF, "Displacement, s",countInputs)
					displacement = float (displacement)
					countInputs = countInputs + 5;
					final_velocity = inputbox.ask(DISPLAY_SURF, "Final Velocity, v",countInputs)
					final_velocity = float (final_velocity)
					countInputs = countInputs + 5;
					time = inputbox.ask(DISPLAY_SURF, "Time, t",countInputs)
					time = float (time)
					if(time < 0):
						errorScreen.errorScreen(DISPLAY_SURF,"Negative time entered")
						run = False
					if(time == 0):
						errorScreen.errorScreen(DISPLAY_SURF,"Time cannot be zero in this case")
						run = False
					acceleration = (final_velocity*time - displacement)*2/time/time
					
					initial_velocity = final_velocity - acceleration*time
					font = pygame.font.Font(None, 36)
					text = font.render("Acceleration hence calculated is "+ str(acceleration) +"meter/sec/sec", 1, WHITE)
					path = "Images/game1/Explanation/Calculate_A/G2/"
					anim1(DISPLAY_SURF,text,final_velocity,initial_velocity,acceleration,time,displacement,path)
					run = False
				elif rect_a3.collidepoint(mouse):
					countInputs = 1;	# countInputs is related to the y coordinate of the input text boxes
					initial_velocity = inputbox.ask(DISPLAY_SURF, "Initial velocity, u",countInputs)
					initial_velocity = float (initial_velocity)
					countInputs = countInputs + 5;
					displacement = inputbox.ask(DISPLAY_SURF, "Displacement, s",countInputs)
					displacement = float (displacement)
					countInputs = countInputs + 5;
					time = inputbox.ask(DISPLAY_SURF, "Time, t",countInputs)
					time = float (time)
					if(time < 0):
						errorScreen.errorScreen(DISPLAY_SURF,"Negative time entered")
						run = False
					if(time == 0):
						errorScreen.errorScreen(DISPLAY_SURF,"Time cannot be zero in this case")
						run = False
					acceleration = ((displacement-initial_velocity*time)/time/time)*2
					
					final_velocity = initial_velocity + acceleration*time
					font = pygame.font.Font(None, 36)
					text = font.render("Acceleration hence calculated is "+ str(acceleration) +"meter/sec/sec", 1, WHITE)
					path = "Images/game1/Explanation/Calculate_A/G3/"
					anim1(DISPLAY_SURF,text,final_velocity,initial_velocity,acceleration,time,displacement,path)
					run = False
				elif rect_a4.collidepoint(mouse):
					countInputs = 1;	# countInputs is related to the y coordinate of the input text boxes
					initial_velocity = inputbox.ask(DISPLAY_SURF, "Initial velocity, u",countInputs)
					initial_velocity = float (initial_velocity)
#.........这里部分代码省略.........
开发者ID:gopal10sep,项目名称:SimPhy-1,代码行数:103,代码来源:AbyNLM.py

示例2: compTbyNLM

# 需要导入模块: from Button import Button [as 别名]
# 或者: from Button.Button import setHoverColor [as 别名]
def compTbyNLM(DISPLAY_SURF):

	btn_t1 = pygame.image.load('Images/buttons/parameters/t1.png') 	
	btn_t2 = pygame.image.load('Images/buttons/parameters/t2.png') 
	btn_t3 = pygame.image.load('Images/buttons/parameters/t3.png') 
	btn_t4 = pygame.image.load('Images/buttons/parameters/t4.png') 

	btn_back = Button('Back')
	btn_back.setColor(RED)
	btn_back.setHoverColor(LIME)
	btn_back.setFontColor(BLUE)
	clock = pygame.time.Clock()
	background=pygame.image.load('Images/game1/input_values.png')
	
	run = True
	
	while run:
		DISPLAY_SURF.blit(background,SCREEN_TOPLEFT)
		mouse = pygame.mouse.get_pos()
		for event in pygame.event.get():
			if event.type == pygame.QUIT:
				run = False
				pygame.quit()
				sys.exit()
			elif event.type == pygame.MOUSEBUTTONDOWN:
				if rect_t1.collidepoint(mouse):
					countInputs = 1;	# countInputs is related to the y coordinate of the input text boxes
					final_velocity = inputbox.ask(DISPLAY_SURF, "Final Velocity, v",countInputs)
					final_velocity = float (final_velocity)
					countInputs = countInputs + 5;
					acceleration = inputbox.ask(DISPLAY_SURF, "Acceleration, a",countInputs)
					acceleration = float (acceleration)
					countInputs = countInputs + 5;
					initial_velocity = inputbox.ask(DISPLAY_SURF, "Initial Velocity, u",countInputs)			
					initial_velocity = float (initial_velocity)
					if(acceleration==0):
						errorScreen.errorScreen(DISPLAY_SURF,"Acceleration cannot be zero in this case")
						run = False
					time = (final_velocity -initial_velocity)/acceleration
					if(time < 0):
						errorScreen.errorScreen(DISPLAY_SURF,"Inconsistent data entered.(results to Negative time)")
						run = False
					displacement = initial_velocity*time + acceleration*time*time/2
					
					font = pygame.font.Font(None, 36)
					text = font.render("The Time hence calculated is "+ str(time) +" sec", 1, WHITE)
					path = "Images/game1/Explanation/Calculate_T/G1/"
					anim1(DISPLAY_SURF,text,final_velocity,initial_velocity,acceleration,time,displacement,path)
					run = False
				elif rect_t2.collidepoint(mouse):
					countInputs = 1;	# countInputs is related to the y coordinate of the input text boxes
					initial_velocity = inputbox.ask(DISPLAY_SURF, "Initial Velocity, u",countInputs)
					initial_velocity = float (initial_velocity)
					countInputs = countInputs + 5;
					displacement = inputbox.ask(DISPLAY_SURF, "Displacement, s",countInputs)
					displacement = float (displacement)
					countInputs = countInputs + 5;
					acceleration = inputbox.ask(DISPLAY_SURF, "Acceleration, a",countInputs)
					acceleration = float (acceleration)
					try :
						final_velocity = math.sqrt(initial_velocity*initial_velocity + 2*acceleration*displacement)
					except :
						errorScreen.errorScreen(DISPLAY_SURF,"Inconsistent data")
					if(acceleration==0):
						if (initial_velocity == 0):
							errorScreen.errorScreen(DISPLAY_SURF,"Inconsistent data")
							run = False
						else :
							time = displacement/initial_velocity
					else :
						time = (final_velocity - initial_velocity)/acceleration
					if(time < 0):
						errorScreen.errorScreen(DISPLAY_SURF,"Inconsistent data entered.(results to Negative time)")
						run = False
					
					font = pygame.font.Font(None, 36)
					text = font.render("The Time hence calculated is "+ str(time) +" sec", 1, WHITE)
					path = "Images/game1/Explanation/Calculate_T/G2/"
					anim1(DISPLAY_SURF,text,final_velocity,initial_velocity,acceleration,time,displacement,path)
					run = False
				elif rect_t3.collidepoint(mouse):
					countInputs = 1;	# countInputs is related to the y coordinate of the input text boxes
					initial_velocity = inputbox.ask(DISPLAY_SURF, "Initiual Velocity, u",countInputs)
					initial_velocity = float (initial_velocity)
					countInputs = countInputs + 5;
					displacement = inputbox.ask(DISPLAY_SURF, "Displacement, s",countInputs)
					displacement = float (displacement)
					countInputs = countInputs + 5;
					final_velocity = inputbox.ask(DISPLAY_SURF, "Final Velocity, v",countInputs)
					final_velocity = float (final_velocity)
					if(displacement==0):
						acceleration = 0
						time = 0
					else :
						acceleration = (final_velocity*final_velocity - initial_velocity*initial_velocity)/2/displacement
						if(acceleration==0):
							errorScreen.errorScreen(DISPLAY_SURF,"Inconsistent data entered.(results to zero acceleration)")
							run = False
						time = (final_velocity - initial_velocity)/acceleration
						if(time < 0):
#.........这里部分代码省略.........
开发者ID:gopal10sep,项目名称:SimPhy-1,代码行数:103,代码来源:TbyNLM.py


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