skip to Main Content

I’m not exactly new to python but wouldn’t I know it well and fully, but I’m completely new to Kivy. It’s just a small thing I’m doing just to start somewhere. I’m working in Visual Studio Code(VSC). Python version 3.10. The idea is: there are 5 buttons, each button has a name, when you click on a button, image(meme) should show up. Here is the full code, terminal, debugger and what is in command prompt:

code
code

Terminal
Terminal

Debugger
Debugger

Command Prompt
Command Prompt

Here is python itself and a folder "Projects"
C:UsersКириллAppDataRoamingMicrosoftWindowsStart MenuProgramsPython 3.10
enter image description here

Here is folder with virtual environment(App_EPQ) and a folder with code(App_code)
C:UsersКириллAppDataRoamingMicrosoftWindowsStart MenuProgramsPython 3.10Projects
enter image description here

Thanks in advance

Tried to rewrite the code but that didn’t work. Tried to find someone with a similar problem no luck there also. No idea what to do next and how to fix it so this is my last hope.

2

Answers


  1. Your class has to inherit a layout as well as App:

        class HBoxLayoutExample(BoxLayout, App)
    

    Another way to do it would be to create a class that builds the app and returns the layout:

        class HBoxLayoutExample(BoxLayout)
        **your code**
    
        class HBoxApp(App):
            def build(self):
                return HBoxLayoutExample
        if __name__ == '__main__':
            HBoxApp().run()
    

    as shown here https://kivy.org/doc/stable/guide/lang.html#designing-with-the-kivy-language

    Login or Signup to reply.
  2. Replace your line:

    return layout, button
    

    with:

    return layout
    

    That’s all. build() method have to return one widget, which in your case is BoxLayout instance.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search