I need to make a countdown and then use it on mobile phone. I heard that kivy is good graphic for mobile phones, so I tried to use this. Im trying to run infinite while loop that will count down the time and the kivy app that will create window and display remaining time, both at the same time. I am also using pygame clocks to time it. But when I run this code the while loop is counting the time, but it only creates white blank window and after some time another window. What am I doing wrong ?
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty
from kivy.uix.floatlayout import FloatLayout
from kivy.lang import Builder
from kivy.uix.image import Image
from kivy.core.window import Window
from multiprocessing import Process
import pygame
class MyFloat(FloatLayout):
def __init__(self, **kwargs):
super(MyFloat, self).__init__(**kwargs)
self.background = Image(source="textures/background.jpg", allow_stretch=True, keep_ratio=False)
self.add_widget(self.background)
class MyApp(App):
def build(self):
return MyFloat()
def check_time():
global days
global hours
global minutes
global seconds
global miliSeconds
miliSeconds -= 1
if miliSeconds < 0:
miliSeconds += 100
seconds -= 1
if seconds < 0:
seconds += 60
minutes -= 1
if minutes < 0:
minutes += 60
hours -= 1
if hours < 0:
hours += 24
days -= 1
if days < 0:
global active
active = False
print("End")
print("days: ", days)
print("hours: ", hours)
print("minutes: ", minutes)
print("seconds: ", seconds)
print("miliseconds: ", miliSeconds)
def loop():
while active:
check_time()
clock.tick(100)
clock = pygame.time.Clock()
days = 0
hours = 0
minutes = 0
seconds = 30
miliSeconds = 0
active = True
if __name__ == "__main__":
p1 = Process(target=loop)
p2 = Process(target=MyApp().run)
p1.start()
p2.start()