'Kivy: how to create a clock without a widget?
I would like to use the clock from Kivy but I would like to do it without using a "Widget". When I run the program, it will open a black window of my widget "Top" (there is no .kv file), and I don't need it.
Maybe there is some other way to do it without Kivy, I need to call the function "game.update" at periodic time intervals. thank your for your help
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.clock import Clock
class Node:
def __init__(self):
self.inTrans = 0
self.outTrans = 0
def update(self):
print(' Node:', self.inTrans, self.outTrans)
self.inTrans = self.outTrans
class REQ():
def __init__(self):
self.outTrans=0
self.inTrans=0
self.count = 0
def update(self):
self.count += 4
print(" requestor update, count:", self.count)
self.outTrans = self.count
return self.outTrans
class RES():
def __init__(self):
self.outTrans=0
self.inTrans=0
def update(self, inT):
print(" responder update input:", inT)
return
class Top(Widget):
def __init__(self):
super(Top, self).__init__()
print("START")
self.frame =0
self.requester = REQ()
self.responder = RES()
self.node0 = Node()
def update(self, dt):
self.frame += 1
print("Frame:", self.frame)
self.node0.outTrans = self.requester.update()
self.responder.update(self.node0.inTrans)
self.node0.update()
return
class TopApp(App):
def build(self):
game = Top()
Clock.schedule_interval(game.update, 1.0 )
return game
if __name__ == '__main__':
TopApp().run()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
