Error in Kivy "Revision format must be X.Y.Z[-tag]"

Viewed 1876

I try to run mi program but for some reason i see this error: "Revision format must be X.Y.Z[-tag]" I dont know what it means.

I have been trying to take some things out of my code to know what is causing it but i havent figured it out yet

Here is my python file:

#!/usr/bin/python
import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.screenmanager import ScreenManager, Screen
kivy.require("1.11.1")

class Inicial(BoxLayout):
    def __init__(self, **kwargs):
        super(Inicial, self).__init__(**kwargs)
        temperaturaActual = "°C"


class MainApp(App):
    def build(self):
        return Inicial

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

Here is my kv file:

#:kivy !

#:kivy !

<Inicial>:
    Label:
        id: "temperatura"
        text: root.temperaturaActual
        size_hint: (.25, .25)
        pos_hint: { 'center_x': .05, 'center_y': .55}
        font_size: 60sp
        font_name: 'C:/Users/mateo/AppData/Local/Microsoft/Windows/Fonts/Roboto-Light'
2 Answers

The #:kivy kv syntax is for declaring the minimum compatible Kivy version. You are declaring a version of !. As the error says, your version must be of the form X.Y.Z[-tag], e.g. 1.11.0.

The simplest solution is to remove the #:kivy lines, they aren't necessary.

The problem that you indicate is because you are incorrectly indicating the header in the .kv as the docs points out:

Syntax of a kv File

A Kivy language file must have .kv as filename extension.

The content of the file should always start with the Kivy header, where version must be replaced with the Kivy language version you’re using. For now, use 1.0:

#:kivy 1.0

# content here

In your case you use #:kivy ! and you repeat it 2 times unnecessarily.

On the other hand you have other errors:

  • Only the Property are accessible from the .kv, in your case current temperature is not.

  • If you are going to indicate a measurement using the units, these should be as strings.

  • The build method must return an object, not a class. In your Initial class which is a class, to return an object you must instantiate it using Initial()

Considering the above, the solution is:

#!/usr/bin/python
import kivy

kivy.require("1.11.1")

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import StringProperty


class Inicial(BoxLayout):
    temperaturaActual = StringProperty()

    def __init__(self, **kwargs):
        super(Inicial, self).__init__(**kwargs)
        self.temperaturaActual = "°C"


class MainApp(App):
    def build(self):
        return Inicial()


if __name__ == "__main__":
    MainApp().run()
#:kivy 1.11.1

<Inicial>:
    Label:
        id: "temperatura"
        text: root.temperaturaActual
        size_hint: (.25, .25)
        pos_hint: {'center_x': .05, 'center_y': .55}
        font_size: "60sp"
        font_name: 'C:/Users/mateo/AppData/Local/Microsoft/Windows/Fonts/Roboto-Light'
Related