Is there any reason why the screen is completely black in the kivy program?

Asked

Viewed 26 times

-1

I’m running into a very annoying problem trying to run the program. I looked at questions similar to mine on the site, but they didn’t give me much light. I need to do a job, but every time I create new files it’s always the same.

When I try to run the program it simply turns black, and I do not know the reason, because the console does not show or indicates any error.

My code . py is as follows::

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.core.window import Window

class Quadro(BoxLayout):
    def __init__(self,**kwargs):
        super().__init__(**kwargs)
        Window.size = (500,500)
    
    def criar(self):
        n = self.ids.nome.text
        c = self.ids.cidade.text        
        result = n + " mora em " + c
        self.ids.resultado.text = result

class testeApp(App):
    def build(self):
        self.title = "Um App qualquer"
        return Quadro()

meuObj = testeApp()
meuObj.run()

And this is my . Kv:

<Quadro>:
    orientation: "vertical"
    Label:
        text: "digite um nome: "
    TextInput:
        text: ""
        id: nome
    
    Label:
        text: "digite uma cidade"
    TextInput:
        text: ""
        id: cidade
    
    Button:
        text: "gerar frase"
        on_release: root.criar()
    
    Label:
        text: "aguardando resposta..."
        id: resultado

Here I show what appears on the console and in the program window:

This code is basically a replica of what I had in a class (this program I had in class goes smoothly), so I beg for some help.

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

1 answer

0


I just managed to find myself, found the reason to turn black. Well I will explain to those who come to have the same problem.

There at the end, in the last class it is necessary that it has the file name . Kv, in my case it is example.Kv, then it should look like:

class exemploApp(App):   #pode ser apenas: exemplo(App)
    def build(self):
        self.title = "Um App qualquer"
        return Quadro()

meuObj = exemploApp()
meuObj.run()

Here’s a screenshot of the program running: inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.