Basic code error in Kivy(Python)

Asked

Viewed 838 times

4

I made a very simple code using Kivy, but give this error that shows in the image below: Erro na hora da execução The code is as follows::

import kivy
kivy.require('1.0.6')

from kivy.app import App
from kivy.uix.button import Button

class MyApp(App):
    def build(self):
        return Button(text='Hello World')

if __name__ in ('__android__', '__main__'):
    MyApp().run()

Could you explain to me what’s wrong?

  • What is the file code base.py?

  • Anderson, the code is what’s in the question.

2 answers

1

On the official website of the Kivy library (https://kivy.org/) you can see an example of usage. The library is already in version 1.10.0.

The following example comes straight from the official website and will display a "Hello World":

from kivy.app import App
from kivy.uix.button import Button

class MyApp(App):
   def build(self):
      return Button(text = 'Hello World')

MyApp().run()

As you can see it’s very similar to your code!

  • 2

    Could edit and explain your answer ? She is entering the list of Low Quality Publications.

  • Edited response! =)

1

I know the question is a few months old, but if anyone is looking for the answer, it’s here.

Some Kivy features require the installation of dependencies, so that these functionalities can work properly. These dependencies are not installed automatically so as not to impair the performance of the application by installing unnecessary things for your project, so they are taken apart.

In the Installation Guide you have the explanation for what you need: https://kivy.org/doc/stable/installation/installation-windows.html

But only by running these two command lines can you get the main dependencies:

pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew 
pip install kivy.deps.gstreamer 

Browser other questions tagged

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