Найти - Пользователи
Полная версия: Таймер
Начало » Python для новичков » Таймер
1
Coolibin
Не могу сообразить как написать таймер, чтоб отсчет был виден в реальном времени и можно было от него отнять, например секунд 10. Буду очень признателен!!!
pill
Google => python timer example =

http://mail.python.org/pipermail/tutor/2004-November/033333.html 3-я сверху

Чуть доработать напильником:
import time
import threading

x = None

class Timer(threading.Thread):
def __init__(self, seconds):
self.runTime = seconds
threading.Thread.__init__(self)
def run(self):
time.sleep(self.runTime)
print "Buzzzz!! Time's up!"

class CountDownTimer(Timer):
def run(self):
global x
counter = self.runTime
for sec in range(self.runTime):
print counter
if x == 1:
print 'BOOM'#
time.sleep(1.0)
counter -= 1
print "Done."
Coolibin
Спасибо братуха!!! Ща до точу.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB