getTimerTime.py 文件源码

python
阅读 69 收藏 0 点赞 0 评论 0

项目:getTimer 作者: maxwellgerber 项目源码 文件源码
def runTime(scr, rollover, topString, bottomString, start=None):
    if(rollover):
        if(start is None):
            t = time()
        else:
            t = time(start.hour, start.minute, start.second)
    else:
        if(start is None):
            t = datetime.time()
        else:
            t = datetime.time(start.hour, start.minute, start.second)

    c = curses.KEY_MAX
    cursor = 3
    while(c != 10):
        displayTime(scr, t, cursor, topString, bottomString)
        c = scr.getch()
        if(c == curses.KEY_RIGHT) and cursor < len(str(t))-1:
            cursor += 1
            if(cursor == 2 or cursor == 5):
                cursor += 1
        elif(c == curses.KEY_LEFT) and cursor > 0:
            cursor -= 1
            if(cursor == 2 or cursor == 5):
                cursor -= 1
        elif(c == curses.KEY_UP):
            t = alterDigitTime(cursor, t, 1)
        elif(c == curses.KEY_DOWN):
            t = alterDigitTime(cursor, t, -1)
        else:
            try:
                i = int(c) - 48
                if(i >= 0 and i < 10):
                    t = updateDigitTime(cursor, t, i)
            except ValueError:
                pass
    return datetime.time(t.hour, t.minute, t.second)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号