记录时间的最佳程序(赛车)
简短版本:
程序用于:
- 控制赛车(汽车)圈速(不得重置)
- 能够用作计时器
- b 能够用作反向计时器(在 X 分:秒内开始,在 00 结束) :00)
长版:
我需要一个程序来控制时间,我需要时间来回(让我选择) 然后我插入开始时间。
我还需要一个程序来控制单圈时间。
如果有人知道这些东西(赛车的东西)的任何程序,我会很感激,即使只有付费解决方案,我仍然想看看它们(我开始用 python 制作一个程序,它可能会很好寻找灵感)
经过一番搜索,我只能找到这个: 这是 python TKinter 中的一个简单时钟......如果有人有更高级的东西......(更容易更改:))
from Tkinter import *
import time
from Tkinter import *
import time
class StopWatch(Frame):
""" Implements a stop watch frame widget. """
def __init__(self, parent=None, **kw):
Frame.__init__(self, parent, kw)
self._start = 0.0
self._elapsedtime = 0.0
self._running = 0
self.timestr = StringVar()
self.makeWidgets()
def makeWidgets(self):
""" Make the time label. """
l = Label(self, textvariable=self.timestr)
self._setTime(self._elapsedtime)
l.pack(fill=X, expand=NO, pady=2, padx=2)
def _update(self):
""" Update the label with elapsed time. """
self._elapsedtime = time.time() - self._start
self._setTime(self._elapsedtime)
self._timer = self.after(50, self._update)
def _setTime(self, elap):
""" Set the time string to Minutes:Seconds:Hundreths """
minutes = int(elap/60)
seconds = int(elap - minutes*60.0)
hseconds = int((elap - minutes*60.0 - seconds)*100)
self.timestr.set('%02d:%02d:%02d' % (minutes, seconds, hseconds))
def Start(self):
""" Start the stopwatch, ignore if running. """
if not self._running:
self._start = time.time() - self._elapsedtime
self._update()
self._running = 1
def Stop(self):
""" Stop the stopwatch, ignore if stopped. """
if self._running:
self.after_cancel(self._timer)
self._elapsedtime = time.time() - self._start
self._setTime(self._elapsedtime)
self._running = 0
def Reset(self):
""" Reset the stopwatch. """
self._start = time.time()
self._elapsedtime = 0.0
self._setTime(self._elapsedtime)
def main():
root = Tk()
sw = StopWatch(root)
sw.pack(side=TOP)
Button(root, text='Start', command=sw.Start).pack(side=LEFT)
Button(root, text='Stop', command=sw.Stop).pack(side=LEFT)
Button(root, text='Reset', command=sw.Reset).pack(side=LEFT)
Button(root, text='Quit', command=root.quit).pack(side=LEFT)
root.mainloop()
if __name__ == '__main__':
main()
Short Version:
Program to:
- control racing (cars) laptimes (it must not reset)
- be able to use as a chronometer
- b able to use as a reverse chronometer (start in X min:secs end in 00:00)
Long Version:
I need a program to control time, I need the time to go forth and back (for me to choose)
and I insert the starting time.
I also need a program to control lap times.
If anyone know any program for these stuff (racing stuff), I would apreciate it, even if there only are paid solution, I still would like to take a look at them (I staring to make a program in python and it could be good for inspiration)
After some search, I could only find this:
It's a simple clock in python TKinter..... if anyone has anything more advanced... (easier to change :) )
from Tkinter import *
import time
from Tkinter import *
import time
class StopWatch(Frame):
""" Implements a stop watch frame widget. """
def __init__(self, parent=None, **kw):
Frame.__init__(self, parent, kw)
self._start = 0.0
self._elapsedtime = 0.0
self._running = 0
self.timestr = StringVar()
self.makeWidgets()
def makeWidgets(self):
""" Make the time label. """
l = Label(self, textvariable=self.timestr)
self._setTime(self._elapsedtime)
l.pack(fill=X, expand=NO, pady=2, padx=2)
def _update(self):
""" Update the label with elapsed time. """
self._elapsedtime = time.time() - self._start
self._setTime(self._elapsedtime)
self._timer = self.after(50, self._update)
def _setTime(self, elap):
""" Set the time string to Minutes:Seconds:Hundreths """
minutes = int(elap/60)
seconds = int(elap - minutes*60.0)
hseconds = int((elap - minutes*60.0 - seconds)*100)
self.timestr.set('%02d:%02d:%02d' % (minutes, seconds, hseconds))
def Start(self):
""" Start the stopwatch, ignore if running. """
if not self._running:
self._start = time.time() - self._elapsedtime
self._update()
self._running = 1
def Stop(self):
""" Stop the stopwatch, ignore if stopped. """
if self._running:
self.after_cancel(self._timer)
self._elapsedtime = time.time() - self._start
self._setTime(self._elapsedtime)
self._running = 0
def Reset(self):
""" Reset the stopwatch. """
self._start = time.time()
self._elapsedtime = 0.0
self._setTime(self._elapsedtime)
def main():
root = Tk()
sw = StopWatch(root)
sw.pack(side=TOP)
Button(root, text='Start', command=sw.Start).pack(side=LEFT)
Button(root, text='Stop', command=sw.Stop).pack(side=LEFT)
Button(root, text='Reset', command=sw.Reset).pack(side=LEFT)
Button(root, text='Quit', command=root.quit).pack(side=LEFT)
root.mainloop()
if __name__ == '__main__':
main()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想使用打包解决方案,您应该尝试一些应用程序:
If you want to go with a packaged solution, you should try some of the apps:
所以你想要的是毫秒级精确的秒表和圈速计时器。
并不是说我尝试过,而是这是我在 google http://www.xnotestopwatch.com/ 上找到的
一个希望我可以投票,因为
import tardis
破解是一个很好的破解。 :PSo what you want is a milliseconds accurate stop watch and lap timer.
Not that I have tried it but heres one I found on google http://www.xnotestopwatch.com/
I wish I could vote, cause that
import tardis
crack was a good one. :P