本文整理汇总了Python中Timer.Timer.stop方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.stop方法的具体用法?Python Timer.stop怎么用?Python Timer.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timer.Timer
的用法示例。
在下文中一共展示了Timer.stop方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GameCounter
# 需要导入模块: from Timer import Timer [as 别名]
# 或者: from Timer.Timer import stop [as 别名]
class GameCounter():
def __init__(self):
self.background = pygame.image.load('resources/background_pause.png').convert_alpha()
self.counter = 10000
self.state = True
self.timer = Timer()
self.font = pygame.font.Font('resources/ThrowMyHandsUpintheAirBold.ttf',300)
self.text_counter = Text(self.font,self.counter,(255,255,255),SCREEN_WIDTH/2,SCREEN_HEIGHT/2)
self.timer.start()
def update(self,screen):
while self.state:
self.counter -= self.timer.time() * 100
if self.counter < 0:
self.state = False
self.timer.stop()
scene.timer.start()
#make text in update, why is a object that renew
self.text_counter = Text(self.font,int(math.ceil(self.counter/4000)),(255,255,255),SCREEN_WIDTH/2,SCREEN_HEIGHT/2)
self._draw(screen)
def _draw(self,screen):
#Doesnt loss images of previous scene
screen.blit(scene.background,(0,0))
screen.blit(scene.title_shadow,(0,0))
scene.level_title.draw(screen)
screen.blit(self.background,(0,0))
self.text_counter.draw(screen)
pygame.display.flip()
示例2: main
# 需要导入模块: from Timer import Timer [as 别名]
# 或者: from Timer.Timer import stop [as 别名]
def main():
LEDGame = Game1(arduinoSerialData, randomInt)
timer = Timer(arduinoSerialData)
strikes = StrikeCounter()
seqAnalyzer = SequenceAnalyzer()
gameInit(seqAnalyzer)
cycles = 0
startTime = 0
currentTime = 0
processingSequence = False
while True:
cycles += 1
if(startTime != 0):
currentTime = time.time() * 1000.0
processingSequence = True
if (currentTime - startTime > 2000.0):
seqAnalyzer.setSequence(str(random.choice(list(constant.SEQUENCEPAIRS.keys()))), arduinoSerialData)
startTime = 0
currentTime = 0
processingSequence = False
if (cycles == constant.MAXCYCLES):
cycles = 0
timer.start()
if arduinoSerialData.inWaiting() > 0:
myData = arduinoSerialData.readline().decode("utf-8")
if(myData[:1] == "2"):
result = timer.stop()
strikes.checkForStrikeIncrement(result)
cycles = 0
#If the data being sent was meant for game 1
if(myData[:1] == "1"):
result = LEDGame.processInput(myData)
strikes.checkForStrikeIncrement(result)
if(myData[:1] == "3" and processingSequence is False):
seqAnalyzer.addCharacter(myData[1])
startTime = seqAnalyzer.checkIfSequenceNeedsProcessing(arduinoSerialData)
else:
print(myData)
checkForGameOver()
示例3: main
# 需要导入模块: from Timer import Timer [as 别名]
# 或者: from Timer.Timer import stop [as 别名]
def main(argv=None):
if argv is None:
argv = sys.argv[1:]
# Setup command line options
parser = OptionParser("usage: %prog [options]")
parser.add_option("-l", "--logdir", dest="logdir", default=".", help="log DIRECTORY (default ./)")
parser.add_option("-f", "--logfile", dest="logfile", default="project.log", help="log FILE (default project.log)")
parser.add_option("-v", "--loglevel", dest="loglevel", default="debug", help="logging level (debug, info, error)")
parser.add_option("-q", "--quiet", action="store_true", dest="quiet", help="do not log to console")
parser.add_option("-n", "--filequiet", action="store_true", dest="fquiet", help="do not log to file")
parser.add_option("-c", "--clean", dest="clean", action="store_true", default=False, help="remove old log file")
# Process command line options
(options, args) = parser.parse_args(argv)
# Setup logger format and output locations
logger = initialize_logging(options)
ti = Timer()
skip_events = []
skip_events = ['Container_Back_Loading','Refuelling','Container_Front_Loading','Container_Front_Unloading']
#skip_events.append('Handler_Deposites_Chocks')
#skip_events.append('Aircraft_Arrival')
#skip_events.append('Aircraft_Departure')
skip_events.append('Jet_Bridge_Positioning')
skip_events.append('Jet_Bridge_Parking')
#skip_events.append('VRAC_Back_Loading')
#skip_events.append('VRAC_Back_Unloading')
#skip_events.append('Push_Back_Positioning')
#skip_events = ['GPU_Arrival','Container_Back_Loading','Refuelling','Aircraft_Departure','Container_Front_Unloading']
data_path = '/usr/not-backed-up/cofriend/data/progol/clean_qtc/new_gt_with_zone_IBL_1protos/'
#file_name = 'msh2.p'
file_name = 'msh_all.p'
ins = pickle.load(open(data_path + file_name))
result = {}
#Visualize results as a table
pt = PT(["Event", "#pos examples", "TP", "FP"])
pt.align["Event"] = "l" # Left align event names
for event in ins.keys():
if event in skip_events:
continue
logger.info(event)
ti.start()
pos_score = 0
neg_score = 0
# Get negative test data
all_events = ins.keys()
all_events.remove(event)
for ev in skip_events:
all_events.remove(ev)
neg_test_data = [ins[i] for i in all_events]
neg_test_data = list(flatten(neg_test_data))
for train_data, pos_test_data in k_fold_cross_validation(ins[event], len(ins[event])):
[hyp, max_dis, avg_dis, min_dis] = train(train_data)
logger.info('-----------------')
logger.info('Avg: ' + repr(avg_dis) + ' Max: ' + repr(max_dis))
pos_score += test(hyp, max_dis, avg_dis, min_dis, pos_test_data, 'pos')
neg_score += test(hyp, max_dis, avg_dis, min_dis, neg_test_data, 'neg')
pt.add_row([event, len(ins[event]), float(pos_score)/len(ins[event]), float(neg_score)/len(ins[event])])
result[event] = [float(pos_score)/len(ins[event]), float(neg_score)/len(ins[event])]
ti.stop()
duration = ti.getTimeStr()
logger.info("Time Taken: " + duration)
logger.info(pt)
示例4: Timer
# 需要导入模块: from Timer import Timer [as 别名]
# 或者: from Timer.Timer import stop [as 别名]
ts = ["readConfig", "drawHists", "readhists", "total", "drawfirst", "readfirst"]
perf = {}
perf[ts[0]] = Timer()
perf[ts[1]] = Timer()
perf[ts[2]] = Timer()
perf[ts[3]] = Timer()
perf[ts[4]] = Timer()
perf[ts[5]] = Timer()
imp.start()
perf[ts[3]].start()
from XMLConfigParser import *
import XMLConfigParser
import os, sys
from ROOT import gROOT, TFile
from Drawer import Drawer
imp.stop()
showPerformance = True
if showPerformance:
print "time passed for importing modules: %s" %imp.getMeasuredTime()
class Plotter:
def __init__(self, configfile):
self.config = ""
if configfile == "":
raise ConfigError, "Configuration file is empty"
elif not os.path.exists(XMLConfigParser.pathToDir + configfile):
示例5: Game
# 需要导入模块: from Timer import Timer [as 别名]
# 或者: from Timer.Timer import stop [as 别名]
class Game():
def __init__(self, level, continent, difficult):
self.level = level
self.continent = continent
self.difficult = difficult
self.current_rating_level = int(levels_rating[self.continent+self.difficult][str(self.level)])
#Colors
self.black = (0,0,0)
self.white = (255,255,255)
self.background = pygame.image.load('resources/levels/'+self.continent+'/bglevel'+str(self.level)+'.jpg').convert()
self.name = Configuration.level_name_json(languageID, self.continent, self.level)
self.font = pygame.font.Font('resources/ThrowMyHandsUpintheAirBold.ttf',35)
self.level_title = Text(self.font,self.name,self.black,SCREEN_WIDTH/3+40,30)
#Timer
self.timer = Timer()
self.tweener = pytweener.Tweener()
self.star = Star(self.difficult)
self.button_returnmenu = Button('resources/button_returnmenu.png',830,30)
self.button_playreboot = Button('resources/button_playreboot.png',900,30)
self.button_pause = Button('resources/button_pause.png',970,30)
self.sprites = pygame.sprite.Group()
self.sprites.add(self.button_returnmenu)
self.sprites.add(self.button_playreboot)
self.sprites.add(self.button_pause)
self.title_shadow = pygame.image.load('resources/sombra_titulo_'+self.difficult+'.png').convert_alpha()
#Pause instance
self.pause = Pause()
#Game_Counter instance
self.game_counter = GameCounter()
self.clock = pygame.time.Clock()
def update(self):
for event in pygame.event.get():
if event.type == QUIT:
exit()
elif event.type == MOUSEBUTTONDOWN:
if self.button_returnmenu.rect.collidepoint(event.pos[0],event.pos[1]):
levelsselector_start(self.continent,self.difficult)
if self.button_pause.rect.collidepoint(event.pos[0],event.pos[1]):
self.timer.stop()
self.pause.status = True
if self.button_playreboot.rect.collidepoint(event.pos[0],event.pos[1]):
game_start(self.level,self.continent,self.difficult)
if (self.star.rect.collidepoint(event.pos[0],event.pos[1])
and not self.star.move):
if android:
android.vibrate(1)
self.star.change_state()
self.tweener.addTween(self.star,x=1024,tweenTime=1, tweenType=pytweener.Easing.Elastic.easeIn)
if self.timer.time()<=4:
#Write rating of level and total rating of continent
levels_rating[self.continent+self.difficult][str(self.level)] = "3"
Configuration.override_rating_json(levels_rating)
self.level_goal = LevelGoal(3)
elif self.timer.time()>4 and self.timer.time()<= 6:
if not self.current_rating_level == 3:
levels_rating[self.continent+self.difficult][str(self.level)] = "2"
Configuration.override_rating_json(levels_rating)
self.level_goal = LevelGoal(2)
elif self.timer.time()> 6:
if (not self.current_rating_level == 2 or
not self.current_rating_level == 3):
levels_rating[self.continent+self.difficult][str(self.level)] = "1"
Configuration.override_rating_json(levels_rating)
self.level_goal = LevelGoal(1)
self.timer.stop()
#print self.timer.time()
self.timer.time()
self.dt = self.clock.tick(60)
self.tweener.update(self.dt/1000.0)
def draw(self,screen):
screen.blit(self.background,(0,0))
screen.blit(self.title_shadow,(0,0))
self.level_title.draw(screen)
self.sprites.draw(screen)
screen.blit(self.star.image,(self.star.x,self.star.y))
pygame.display.flip()
#Instance pause with funcion update. Parameters: screen. __draw()
self.pause.update(screen)
#Instance GameCounter with funcion update. Parameters: screen. __draw()
self.game_counter.update(screen)
#Instance LevelGoal with funcion update. Parameters: screen. __draw()
if self.star.x > 1000:
#.........这里部分代码省略.........
示例6: start
# 需要导入模块: from Timer import Timer [as 别名]
# 或者: from Timer.Timer import stop [as 别名]
class Activity:
""" Base class mandatory for any SP activty.
The activity is started by instancing this class by the core.
This class must at least provide the following methods.
start (self) called by the core before calling 'next_level'.
post_next_level (self) called once by the core after 'next_level' *and* after the 321 count.
next_level (self,level) called by the core when the user changes levels.
loop (self,events) called 40 times a second by the core and should be your
main eventloop.
get_helptitle (self) must return the title of the game can be localized.
get_help (self) must return a list of strings describing the activty.
get_helptip (self) must return a list of strings or an empty list
get_name (self) must provide the activty name in english, not localized in lowercase.
stop_timer (self) must stop any timers if any.
"""
def __init__(self,SPGoodies):
"""SPGoodies is a class object that SP sets up and will contain references
to objects, callback methods and observers
TODO: add more explaination"""
self.logger = logging.getLogger("childsplay.photoalbum.Activity")
self.logger.info("Activity started")
self.SPG = SPGoodies
self.lang = self.SPG.get_localesetting()[0][:2]
self.theme = self.SPG.get_theme()
self.screen = self.SPG.get_screen()
self.screenclip = self.SPG.get_screenclip()
self.blit_pos = self.screenclip.left, self.screenclip.top
self.orgscreen = pygame.Surface(self.screenclip.size) # we use this to restore the screen
self.orgscreen.blit(self.screen, (0, 0), self.screenclip)
self.backgr = self.SPG.get_background()
self.blacksurf = pygame.Surface((800, 600)).convert(8)
self.blacksurf.fill(BLACK)
# The location of the activities Data dir
self.my_datadir = os.path.join(self.SPG.get_libdir_path(),'CPData','PhotoalbumData')
self.thumbsdir = os.path.join(self.my_datadir, 'thumbs')
if not os.path.exists(self.thumbsdir):
os.mkdir(self.thumbsdir)
self.shelvepath = os.path.join(self.thumbsdir, 'thumbs.db')
# Location of the CPData dir which holds some stuff used by multiple activities
self.CPdatadir = os.path.join(self.SPG.get_libdir_path(),'CPData')
self.importDir = os.path.join(HOMEDIR, 'braintrainer', 'PicImport', self.lang)
# Location of the alphabet sounds dir
self.absdir = self.SPG.get_absdir_path()# alphabet sounds dir
self.rchash = utils.read_rcfile(os.path.join(self.my_datadir, 'photoalbum.rc'))
self.rchash['theme'] = self.theme
# You MUST call SPInit BEFORE using any of the SpriteUtils stuff
# it returns a reference to the special CPGroup
self.actives = SPSpriteUtils.SPInit(self.screen,self.backgr)
self.timer = None
self.timerpause = int(self.rchash[self.theme]['pause'])
# We use old fashion surfs to blit on the screen iso buttons as transbuttons
# with dynamic background would store a complete background surface each in memory!!
quit_surf = utils.load_image(os.path.join(self.my_datadir, 'quit.icon.png'))
quitro_surf = utils.load_image(os.path.join(self.my_datadir, 'quit_ro.icon.png'))
main_exit_pos = (800 - quit_surf.get_size()[0], 0)
self.main_exit_but = SPWidgets.TransImgButton(quit_surf, quitro_surf, pos=main_exit_pos)
self.main_exit_but.connect_callback(self.main_exit_but_cbf, MOUSEBUTTONDOWN)
self.main_exit_but.set_use_current_background(True)
#self.main_exit_rect = pygame.Rect(self.main_exit_pos + self.main_exit_surf.get_size())
exit_surf = utils.load_image(os.path.join(self.my_datadir, 'category.icon.png'))
exitro_surf = utils.load_image(os.path.join(self.my_datadir, 'category_ro.icon.png'))
exit_pos = (0, 0)
self.exit_but = SPWidgets.TransImgButton(exit_surf, exitro_surf, pos=exit_pos)
self.exit_but.connect_callback(self.exit_but_cbf, MOUSEBUTTONDOWN)
self.exit_but.set_use_current_background(True)
play_surf = utils.load_image(os.path.join(self.my_datadir, 'play.icon.png'))
playro_surf = utils.load_image(os.path.join(self.my_datadir, 'play_ro.icon.png'))
play_pos = (0, 490 - play_surf.get_size()[1])
self.play_but = SPWidgets.TransImgButton(play_surf, playro_surf, pos=play_pos)
self.play_but.connect_callback(self.play_but_cbf, MOUSEBUTTONDOWN)
#self.play_but.set_use_current_background(True)
text_surf = utils.load_image(os.path.join(self.my_datadir, 'text.icon.png'))
textro_surf = utils.load_image(os.path.join(self.my_datadir, 'text_ro.icon.png'))
text_pos = (800 - text_surf.get_size()[0], 490 - text_surf.get_size()[1])
self.text_but = SPWidgets.TransImgButton(text_surf, textro_surf, pos=text_pos)
self.text_but.connect_callback(self.text_but_cbf, MOUSEBUTTONDOWN)
self.text_but.set_use_current_background(True)
self.buttons_list = [self.play_but, self.main_exit_but, self.exit_but]
self.text_label = None
self.text_back = utils.load_image(os.path.join(self.my_datadir, 'text_backgr.png'))
self.textstring = ''
self.prev_mouse_pos = None
self.SPG.tellcore_set_dice_minimal_level(6)
self.clear_screen()
def __del__(self):
self.SPG.tellcore_enable_menubuttons()
def clear_screen(self):
self.screen.blit(self.blacksurf, (0, 0))
#.........这里部分代码省略.........