• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python simpleguitk.create_timer函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中simpleguitk.create_timer函数的典型用法代码示例。如果您正苦于以下问题:Python create_timer函数的具体用法?Python create_timer怎么用?Python create_timer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: process_bonus

def process_bonus(bonus):
    global lives, explosion_group, cant_rocks, rock_group, timer3, score, \
        immortal, scoreBonus, seconds, functionTimer
    if bonus.type == 3:  # lives++
        lives += 1
    elif bonus.type == 4:  # exploit all the asteroids
        copy = rock_group.copy()
        for i in copy:
            explosion_group.add(Sprite(i.get_position(), [0, 0], 0, 0,
                                       explosion_image, explosion_info,
                                       WIDTH, HEIGHT, explosion_sound))
            rock_group.discard(i)
            cant_rocks -= 1
            score += 1
    else:
        if bonus.type == 2:  #each asteroid is +2
            scoreBonus = True
            immortal = False
        elif bonus.type == 1:  #the asteroids not hurt you
            immortal = True
            scoreBonus = False

        if timer3 is not None:
            timer3.stop()
            seconds = 0

        timer3 = simplegui.create_timer(1000, timer_bonus_1_2)
        tick_tock_sound.rewind()
        tick_tock_sound.play()
        timer3.start()
开发者ID:ErisoHV,项目名称:Asteroids,代码行数:30,代码来源:Asteroids.py


示例2: move

def move():
    global snake, bean, direction, gameover, score, time_interval, timer
    if not gameover:
        if direction == RIGHT:
            head = [snake[0][0]+1, snake[0][1]]
        elif direction == UP:
            head = [snake[0][0], snake[0][1]-1]
        elif direction == LEFT:
            head = [snake[0][0]-1, snake[0][1]]
        elif direction == DOWN:
            head = [snake[0][0], snake[0][1]+1]
        # 检查游戏结束条件    
        if head[0] >= COLS or head[0] < 0 or head[1] >= ROWS or head[1] < 0 or (head in snake):
            gameover = True
            return
        
        snake.insert(0, head)   
        tail = snake.pop()
        if bean in snake: # 如果吃到豆子
            bean = create_bean()
            snake.append(tail)
            score += 1    
            if score > 0 and score % 5 == 0 and time_interval > 50:
                simplegui.timers.destroy() # 先销毁原有 timer,再创建新的 timer
                time_interval /= 1.2
                timer = simplegui.create_timer(time_interval, move)    
                timer.start()
开发者ID:wzmdream,项目名称:similarity_check,代码行数:27,代码来源:snake_solution.py


示例3: main

def main():
    global TIME_INTERVAL, frame, timer
    #create a timer with timed event
    timer = simplegui.create_timer(TIME_INTERVAL, incrementTime)
    #create frame
    frame = createFrame()
    
    #start frame
    frame.start()
开发者ID:CardenB,项目名称:pyGames,代码行数:9,代码来源:StopWatchGame.py


示例4: reset

def reset():    
    """ Reset stopwatch and score """
    global timer, counter, message, attempts, hits, is_running, sucs_message
    timer.stop()
    is_running = False
    timer = simplegui.create_timer(100, tick)
    counter = 0
    attempts = 0
    hits = 0
    sucs_message = ""
开发者ID:vogonwann,项目名称:coursera,代码行数:10,代码来源:stopwatch.py


示例5: timer_handler

def timer_handler():
    global x
    x += 4
    print x
    print time.time()
    print ""
    global timer
    if x >= 16:
        timer.stop()
        timer = simpleguitk.create_timer(500, timer_handler)
        timer.start()
开发者ID:onthrak,项目名称:python_courses,代码行数:11,代码来源:timers+start+and+stop.py


示例6: play

def play():
    global snake, bean, direction, gameover, score, time_interval, timer
    # 如果有正在运行的定时器,需要先把它停下
    if timer is not None and timer.is_running():
        timer.stop() 
    # 创建定时器
    timer = simplegui.create_timer(time_interval, move)
    timer.start()
    
    # 代码写在下面
    pass  
开发者ID:wzmdream,项目名称:similarity_check,代码行数:11,代码来源:snake.py


示例7: createWorld

    def createWorld(self):
        world = gui.create_frame("Robot World",self.worldX,self.worldY)
        world.set_canvas_background(GUI.WORLD_COLOR)

        self.txtSetDist = world.add_input("Set Distance", self.txtDestDistance,50)
        self.btnSetDist = world.add_button("Set Distance",self.setDistHandler,50)
        self.btnMove = world.add_button("Move",self.moveHandler, 50)

        timer = gui.create_timer(500,self.timerHandler)

        world.set_draw_handler(self.renderingHandler)

        timer.start()  
        world.start()
开发者ID:monica-p,项目名称:YorkU-Minnow,代码行数:14,代码来源:GUI.py


示例8: play

def play():
    global snake, bean, direction, gameover, score, time_interval, timer
    # 如果有正在运行的定时器,需要先把它停下
    if timer is not None and timer.is_running():
        timer.stop() 
    # 创建定时器
    timer = simplegui.create_timer(time_interval, move)
    timer.start()
    
    snake = create_snake()
    bean = create_bean()
    direction = LEFT
    score = 0
    gameover = False
    time_interval = 200  
开发者ID:wzmdream,项目名称:similarity_check,代码行数:15,代码来源:snake_solution.py


示例9: __init__

    def __init__(self, puzzle):
        """
        Create frame and timers, register event handlers
        """
        self._puzzle = puzzle
        self._puzzle_height = puzzle.get_height()
        self._puzzle_width = puzzle.get_width()

        self._frame = simplegui.create_frame("The Fifteen puzzle",
                                             self._puzzle_width * TILE_SIZE,
                                             self._puzzle_height * TILE_SIZE)
        self._solution = ""
        self._current_moves = ""
        self._frame.add_button("Solve", self.solve, 100)
        self._frame.add_input("Enter moves", self.enter_moves, 100)
        self._frame.add_button("Print moves", self.print_moves, 100)
        self._frame.set_draw_handler(self.draw)
        self._frame.set_keydown_handler(self.keydown)
        self._timer = simplegui.create_timer(50, self.tick)
        self._timer.start()
        self._frame.start()
开发者ID:flail-monkey,项目名称:principles1,代码行数:21,代码来源:poc_fifteen_gui.py


示例10: key_down

        
def key_down(key):
    if key == simplegui.KEY_MAP["space"]: 
        game_begin()
   
def input_handler(text_input):
    global lives
    if text_input.isdigit(): 
        lives = int(text_input)

# initialize frame
frame = simplegui.create_frame("Asteroids", WIDTH, HEIGHT)
inp = frame.add_input('初始阳光:', input_handler, 50)
inp.set_text(1000)

# register handlers
frame.set_draw_handler(draw)
frame.set_keydown_handler(key_down)
frame.set_mouseclick_handler(mouseclick)

timer = simplegui.create_timer(random.randint(500, zombie_interval), zombie_spawner)
timer1 = simplegui.create_timer(5000.0, sunshine_spawner)
timer2 = simplegui.create_timer(1000.0, bullet_spawner)
timer3 = simplegui.create_timer(100.0, flower_sunshine_spawner)

# get things rolling
timer.start()
timer1.start()
timer2.start()
timer3.start()
frame.start()
开发者ID:wzmdream,项目名称:similarity_check,代码行数:30,代码来源:pvz1.py


示例11: draw

def draw(canvas):  
    line_width = random.randrange(0,6,2)
    line_color = random.choice(color_list)
    fill_color = random.choice(color_list)
    font_color = random.choice(color_list) 
    if choice ==1:
        radius = random.randint(1,10)
        circle_x = random.randrange(radius, WIDTH-radius)
        circle_y = WIDTH/2 * random.random()
        radius = random.randint(1,20)    
        canvas.draw_circle([circle_x,circle_y], radius, line_width, line_color, fill_color)
    if choice == 2:
         point_list = [[random.randrange(0, WIDTH),random.randint(0,HEIGHT)],[WIDTH/2,HEIGHT/2]]
         canvas.draw_polygon(point_list, line_width, line_color, fill_color)
    if choice == 3:
        point =[random.randrange(0, WIDTH),random.randint(0,HEIGHT)]
        font_size = random.choice([6,8,12,24,36,64])
        canvas.draw_text(text, point, font_size, font_color)
            
frame = simplegui.create_frame("屏幕保护程序",400, 400)

frame.add_button("画圆效果", click1, 50)
frame.add_button("折线效果", click2, 50)
frame.add_button("文字效果", click3, 50)
frame.add_input("请输入出现在屏保上的文字:",input,100)
frame.add_button("清空", pause, 50)

frame.set_draw_handler(draw)
timer = simplegui.create_timer(5000,timer_handler)

frame.start()
开发者ID:wzmdream,项目名称:similarity_check,代码行数:31,代码来源:ScreenSave.py


示例12: Grid

    timer.stop()
    inplay = True
    grid = Grid()
    score = 0
    current_shape = create_shape()    
    timer.start()

def keydown(key):
    if key == simplegui.KEY_MAP['space']:
        current_shape.rotate(grid)
    if key == simplegui.KEY_MAP['left']:
        current_shape.move('left', grid)
    if key == simplegui.KEY_MAP['right']:
        current_shape.move('right', grid)
    if key == simplegui.KEY_MAP['down']:
        current_shape.move('down', grid)        
    

# 创建用户界面
frame = simplegui.create_frame("俄罗斯方块", WIDTH, HEIGHT)
frame.set_draw_handler(draw)
frame.set_keydown_handler(keydown)

# 创建按钮
frame.add_button("开始游戏", play, 80)
# 创建定时器
timer = simplegui.create_timer(TIME_INTERVAL, move)

play()
frame.start()
开发者ID:wzmdream,项目名称:similarity_check,代码行数:30,代码来源:tetris.py


示例13: keydown

# 按键事件响应函数    
def keydown(key):
    global score
    try:
        ch = chr(key)
    except:     # 捕捉 TypeError 或其它异常
        return  # 不做任何处理
    else:
        pass
        # 代码填在这里
            

# 换一个词            
def change_word():
    global word, flag, pointer, score
    pass
    

# 创建用户界面
frame = simplegui.create_frame("疯狂英语", WIDTH, HEIGHT)
frame.set_canvas_background("White")
frame.set_draw_handler(draw)
frame.set_keydown_handler(keydown)

# 创建按钮
frame.add_button("开始游戏", play, 80)
# 创建定时器
timer = simplegui.create_timer(TIME_INTERVAL, change_word)

play()
frame.start()
开发者ID:wzmdream,项目名称:similarity_check,代码行数:31,代码来源:crazy_english.py


示例14: demo1

def demo1():
    # Register handler
    timer = simplegui.create_timer(1000, tick)
    # Start timer
    timer.start()
开发者ID:tdongsi,项目名称:python,代码行数:5,代码来源:SimpleGuiDemo.py


示例15: start_game

# 为游戏开始或重新开始初始化全局变量,也是鼠标点击按钮的事件处理函数
def start_game():
    global prime_sentence_list, stopped_box, rising_box,current_section_list, has_rising_box, game_over, score, last_four_box
    score = 0
    label.set_text("游戏得分 = 0分")
    game_over = False
    prime_sentence_list = read_from_file('三字经.txt')
    stopped_box = set([])
    last_four_box = []
    current_section_list = generate_current_section_list()
    rising_sentence = current_section_list.pop()
    rising_box = Box([0,canvas_height], box_width, box_height, text_shuffle(rising_sentence[1:]), rising_sentence[1:], int(rising_sentence[0]))

    has_rising_box = True

# 创建窗口初始化画布
frame = simplegui.create_frame("挑战《三字经》", canvas_width, canvas_height)
label = frame.add_label("游戏得分 = 0分")

# 注册事件处理函数
frame.set_keydown_handler(keydown)                         # 按键处理,每次按键会调用keydown函数
frame.set_draw_handler(draw)                               # 显示处理,每秒调用draw函数60次
timer = simplegui.create_timer(1000.0, box_spawner)        # 每秒调用box_spawner函数1次
button = frame.add_button('重新开始游戏', start_game, 100)   # 鼠标每次点击“重新开始游戏”按钮,调用start_game函数1次

# 启动游戏
start_game()     # 为游戏开始或重新开始初始化全局变量
timer.start()    # 启动定时器
frame.start()    # 显示窗口
开发者ID:wzmdream,项目名称:similarity_check,代码行数:29,代码来源:ThreeCharacterPrimer.py


示例16: timerhandler

# define event handler for timer with 0.1 sec interval
def timerhandler():
    global timer_counter
    timer_counter +=1
    return
# define draw handler    
def draw_handler(canvas):
    canvas.draw_text(format(timer_counter), (CANVAS_WIDTH//2, CANVAS_HEIGHT//2), FONT_SIZE, "Red")
    score="Score: "+ convert(success_counter)+"/"+ convert(stop_counter)
    canvas.draw_text(score, (10,20), FONT_SIZE_SCORE, "White")




    
# create frame
frame = simplegui.create_frame("Stopwatch", CANVAS_WIDTH, CANVAS_HEIGHT)

# register event handlers

timer = simplegui.create_timer(10, timerhandler)
frame.set_draw_handler(draw_handler)
start_button = frame.add_button("Start", start_handler, 100)
stop_button = frame.add_button("Stop", stop_handler, 100)
reset_button = frame.add_button("Reset", reset_handler, 100)

# start frame
frame.start()

# Please remember to review the grading rubric
开发者ID:fatmazaman,项目名称:Python-games,代码行数:30,代码来源:stopwatch.py


示例17: elapse

    running=False

# define event handler for timer with 0.1 sec interval
def elapse():
    global time_general
    time_general+=1
    format(time_general)
    
# define draw handler
def draw(canvas):
    canvas.draw_text(time_string, [40, 120], 50, "White")
    canvas.draw_text(score_string, [130, 32], 40, "Green")
    
# create frame
frame=simplegui.create_frame('Stopwatch', 200, 200)

# register event handlers
frame.add_button('Start', start, 120)
frame.add_label('')
frame.add_button('Stop', stop, 120)
frame.add_label('')
frame.add_button('Reset', reset, 120)

frame.set_draw_handler(draw)
timer = simplegui.create_timer(100, elapse)

# start frame
frame.start()

# Please remember to review the grading rubric
开发者ID:YangChuan80,项目名称:Coursera,代码行数:30,代码来源:Mini_Project_03.py


示例18: imprimir

    global time , aciertos, intentos
    time = 0
    aciertos = 0
    intentos = 0
    timer.stop()

# define event handler for timer with 0.1 sec interval
def imprimir():
    global time
    time +=1


# define draw handler
def draw(canvas):
    canvas.draw_text(format(time),[60,110],35,"white")
    canvas.draw_text(resultados(), [150,20], 24 , "green")


# create frame
marco = simplegui.create_frame("StopWatch", 200,200)
marco.add_button("Start", start, 100)
marco.add_button("Stop", stop, 100)
marco.add_button("Reset", reset, 100)

marco.set_draw_handler(draw)
# register event handlers
timer = simplegui.create_timer(100,imprimir)

# start frame
marco.start()
开发者ID:l222p,项目名称:Python,代码行数:30,代码来源:StopWatch.py


示例19: start_timer

    hits = 0
    timer.stop()


# Event handler for timer with 0.1 sec interval
def start_timer():
    global started, time
    if started == True:
        time += 1


# Draw handler
def draw(canvas):
    canvas.draw_text(format(time), [80, 170], 40, "Teal")
    canvas.draw_text(str(hits) + "/" + str(count), [225, 45], 20, "Magenta")


# Create frame
frame = simplegui.create_frame("Stopwatch Game", 300, 300)
timer = simplegui.create_timer(100, start_timer)

# Register event handlers
frame.set_draw_handler(draw)
frame.add_button("Stop", stop_button, 100)
frame.add_button("Start", start_button, 100)
frame.add_button("Reset", reset, 100)

# start frame
frame.start()
timer.start()
开发者ID:cyrne2,项目名称:stopwatch,代码行数:30,代码来源:stopwatch.py


示例20: increment

def increment():
    global tenth_sec
    tenth_sec += 1


# define draw handler
def draw(canvas):
    global tenth_sec
    global flag
    canvas.draw_text( format(tenth_sec), [100,100], 24, "White")
    canvas.draw_text( game(), [150,20], 24, "White")
    
# create frame
f=simplegui.create_frame("",200,200)


# register event handlers
timer=simplegui.create_timer(100,increment)
f.add_button("Start",start,100)
f.add_button("Stop",stop,100)
f.add_button("Reset",reset,100)
f.set_draw_handler(draw)


# start frame
f.start()



# Please remember to review the grading rubric
开发者ID:rajats,项目名称:Interactive-programming-in-python-course,代码行数:30,代码来源:stopwatch_game.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python simpleguitk.load_image函数代码示例发布时间:2022-05-27
下一篇:
Python simpleguitk.create_frame函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap