Hello.
I have copied these 2 files of code from a website.

main.py:

from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout
from kivy.clock import Clock
from kivy.properties import StringProperty

import datetime

class Counter_Timer(BoxLayout):
    def update(self, dt):
            delta = datetime.datetime(2015, 9, 13, 3, 5) - datetime.datetime.now()
            self.days = delta.days
            hour_string = str(delta).split(',')[1]
            self.hours = hours_string.split(':')[0]
            self.minuts = hours_string.split(':')[1]
            self.seconds = hours_string.split(':')[2].split('.')[0]
            return days, hours, minuts, seconds

class Counter(App):
    def build(self):
        counter = Counter_Timer
        Clock.schedule_interval(counter.update, 1.0)
        days = StringProperty()
        hours = StringProperty()
        minutes = StringProperty()
        seconds = StringProperty()
        return

if __name__ == "__main__":
    Counter().run()

There was written:
"Let's add them to the Counter_timer class:"

days = StringProperty()
hours = StringProperty()
minutes = StringProperty()
seconds = StringProperty()

So i added it into the def build. correct place,right?
And i add it myself, but i'm not sure if it's correct or not:
from kivy.properties import StringProperty

And here is the next file counter.kv:

<Counter_Timer>:
    orientation: 'vertical'
    Label:
        text: 'Vacation starts in:'
        font_size: '46dp'
    Label:
        text: root.days + ' Days'
        font_size: '46dp'
    Label:
        text: root.hours + ' Hours'
        font_size: '38dp'
    Label:
        text: root.minuts + ' Minuts'
        font_size: '30dp'
    Label:
        text: root.seconds + ' Seconds'
        font_size: '22dp'

When i run it, i get this error:

[INFO   ] Kivy v1.8.0
Purge log fired. Analysing...
Purge 4 log files
Purge finished !
[INFO   ] [Logger      ] Record log in /home/niloofar/.kivy/logs/kivy_15-02-24_5.txt
[INFO   ] [Factory     ] 157 symbols loaded
[DEBUG  ] [Cache       ] register <kv.lang> with limit=None, timeout=Nones
[DEBUG  ] [Cache       ] register <kv.image> with limit=None, timeout=60s
[DEBUG  ] [Cache       ] register <kv.atlas> with limit=None, timeout=Nones
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_pygame, img_pil, img_gif 
[DEBUG  ] [Cache       ] register <kv.texture> with limit=1000, timeout=60s
[DEBUG  ] [Cache       ] register <kv.shader> with limit=1000, timeout=3600s
[INFO   ] [Text        ] Provider: pygame
[DEBUG  ] [App         ] Loading kv <./counter.kv>
[CRITICAL] [Application ] No window is created. Terminating application run.

What should i do?

Dani AI

Generated

The immediate cause of the Kivy message ("No window is created") is that the App's build() does not return a widget object. That happens here because the code assigns the class instead of creating an instance, and because the widget properties were placed inside build instead of at class scope. There are also several small naming/logic bugs in the update routine (mismatched variable names and a stray return), plus a spelling mismatch between the KV (minuts) and the Python property (minutes). This echoes 's suggestion to check the log — the log is showing a valid symptom of a build that returned None.

Practical fixes to apply:

  • Declare the four StringProperty attributes at class level inside Counter_Timer (not inside build). Keep their names and the KV names consistent (rename minuts in the KV to minutes or vice versa).
  • In build() create an instance (for example, counter = Counter_Timer()), schedule the clock on that instance (e.g. Clock.schedule_interval(counter.update, 1)), and then return counter. Returning the instance is required for Kivy to create the window.
  • In update(self, dt) compute the delta, extract days from delta.days and get hours/minutes/seconds from delta.seconds using divmod, assign those values to the class properties (e.g. self.days = str(delta.days)), and remove any return from update. Also fix typos like hour_string vs hours_string.

Extra notes: if problems persist, look for tracebacks in the log produced during build() or the first update() call (an exception there can abort window creation). Kivy auto-loads counter.kv when the App class is named Counter, so keep filenames and class names consistent.

Error messages are poor with .kv files.
One reason I don't like them.
Check your log file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.