0

Currently I have a Raspberry Pi 1 Rev2 model B and a Raspberry Pi 3, I'm developing an app that could check dynamic values from several screens, I'm using a 7inch LCD Screen to look the graphics generated from the kivy app.

The problem is that when I test codes that I could use to my code, they are tested in windows 10 and works great, however, when I pasted this code inside the Raspberry Pi and run it, the screen goes black and I can't see nothing more, also the touchscreen doesn't work in the kivy app (It works ok outside of the kivy app).

I started to think that was something related with the kivy versions, so I check them:

Windows 10 kivy version: 1.10.0 Raspberry Pi kivy version: 1.10.1.dev0 (I don't know what's the meaning of dev0)

So I use the line code: import kivy kivy.requires('1.10.0')

Without any good results, I will paste a code from another thread from here in StackOverflow, however, I missed the link so forgive me that:

This is only a code that I wanted to test to use the same logic for my purposes, it will change the label text dynamically.

YourApp.py

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.properties import StringProperty
import random

class YourWidget(Widget):
    random_number = StringProperty()

    def __init__(self, **kwargs):
        super(YourWidget, self).__init__(**kwargs)
        self.random_number = str(random.randint(1, 100))

    def change_text(self):
        self.random_number = str(random.randint(1, 100))

class YourApp(App):
    def build(self):
        return YourWidget()

if __name__ == '__main__':
    YourApp().run()

YourApp.kv

<YourWidget>:
    BoxLayout:
        size: root.size
        Button:
            id: button1
            text: "Change text"
            on_release: root.change_text()
        Label:
            id: label1
            text: root.random_number

Let me know what ideas you have to help with this, it's really annoying that I can't keep going for this kind of problems.

Thanks.

0

I had a similar situation and the problem was that kivy has a stricter naming convention for the kv file in linux than windows from what I think.

Try renaiming your kv to Your.kv and your.kv

If this does not help explicitly load your kv file with

Builder.load_file('path/to/file.kv')

or use

Builder.load_string("""
... """")

Maybe you can also upload the log file you get when starting kv

-1

Change your .py to Your.py and .kv to Your.kv and the name before App must be same as kv file name(Case sensitive).

  • Why does should it help? We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed or you risk to get down votes. Please take the short Tour and visit the Help Center to get an idea how things work here. – Ingo May 24 at 19:36
  • He named his app name as YourApp(App) in his python code in order to bind his kv file to his py file – Adhun Thalekkara May 25 at 3:06
  • Please can you elaborate it in your answer? You can edit it. And yes, it is really a good idea for you to take the Tour :-) – Ingo May 25 at 8:29
  • he Built an App class YourApp(App) so it will try to bind a kv file named Your.kv (whatever written before App) its case sensitive too – Adhun Thalekkara Nov 25 at 7:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.