简体   繁体   中英

Kivy - Black screen -

I'm working with Kivy in Ubuntu. When I write the widgets on the.kv file, it's all successful, but when I try the code syntax, it just appears a blank screen and I have no idea what to do. Someone please help.

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.widget import Widget

class BoxLayoutExample(BoxLayout):
    def __int__(self, **kwargs):
        super().__init__(**kwargs) 
        self.orientation = "vertical"
        b1 = Button(text="A")
        b2 = Button(text="B")
        b3 = Button(text="C")
        self.add_widget(b1)
        self.add_widget(b2)
        self.add_widget(b3)
    

class TheLabApp(App):
    pass


TheLabApp().run()

This line was changed:

        super(BoxLayoutExample, self).__init__(**kwargs)
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.widget import Widget

class BoxLayoutExample(BoxLayout):
    def __init__(self, **kwargs):
        super(BoxLayoutExample, self).__init__(**kwargs)
        self.orientation = "vertical"
        b1 = Button(text="A")
        b2 = Button(text="B")
        b3 = Button(text="C")
        self.add_widget(b1)
        self.add_widget(b2)
        self.add_widget(b3)


class TheLabApp(App):
    def build(self):
        return BoxLayoutExample()


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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM