Reputation: 3796
I am trying to discover a similar wx.Timer method in Kivy to create a basic stop watch. I achieved this in wxPython, but not clear on how to achieve this in Kivy (a new framework that I've just come across. Additionally, Kivy does not appear to have an LED number display like in wx.Python. Here is how I achieved this using wxPython, more or less:
import wx
import wx.gizmos as gizmos
import win32api
import time
class LED_timer(wx.Frame):
def __init__(self, parent, id):
pos = wx.DefaultPosition
wx.Frame.__init__(self, parent, id, title='Stop Watch', pos=pos, size=(350, 100), style= wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX)
size = wx.DefaultSize
style = gizmos.LED_ALIGN_CENTER
self.led = gizmos.LEDNumberCtrl(self, -1, pos, size, style)
...
...
...
self.timer = wx.Timer(self, TIMER_ID)
# update timer every 1/10 second (100ms)
#self.timer.Start(100)
self.timer.Stop()
ts = self.t_format(start_time)
self.led.SetValue(ts)
...
...
...
def OnTimer(self, event):
global start_time
start_time += 1
ts = self.t_format(start_time)
self.led.SetValue(ts)
...
...
...
...
Upvotes: 0
Views: 50
Reputation: 4693
Timer in Kivy is called Clock. You could create a stop watch with it easily.
About LED display, it is called segment display, and you can download it from kivy garden. Refer here for more info about garden package manager.
Upvotes: 2