Kivy:Kivy发射器倒下了

时间:2017-11-30 12:58:45

标签: python kivy

我有简单的kivy代码,在W10运行没有问题。它在装载kivy发射器时掉下来。问题没有消息。

from kivy.app import App
from kivy.uix.widget import Widget

from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.uix.button import Button

class View(BoxLayout):
    def __init__(self):
        super().__init__()
        self.text = "No text"
        but = Button(text = "Press",on_press = self.show)
        self.add_widget(but)
        self.lbl = Label()
        self.add_widget(self.lbl)

    def show(self,obj):
        self.lbl.text = self.text
        pass



class MyPaintApp(App):

    def build(self):
        return View()


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

2 个答案:

答案 0 :(得分:2)

由于您拨打super错误,因此无法运行 由于kivy启动器使用python 2,你需要将你的类(View)和实例(self)传递给super。

您需要像这样编辑您的课程:

class View(BoxLayout):
    def __init__(self,**kwargs):
        super(View,self).__init__(**kwargs)

答案 1 :(得分:-1)

在kivy启动器的每一次故障中,项目目录中都有一个具有完整日志的'.kivy / log'目录。您可以在那里找到所有问题。