简体   繁体   English

Kivy - 黑屏 -

[英]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.我正在 Ubuntu 中使用 Kivy。当我在 .kv 文件上编写小部件时,一切都成功了,但是当我尝试代码语法时,它只是出现一个空白屏幕,我不知道该怎么做。 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()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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