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)
评论列表
文章目录