一切似乎都很完美,但是在Kivy屏幕上,什么都没有出现,只有黑屏!我试图重新排列导入位置,甚至安装了pygame,但问题仍然存在!
import kivy
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
from kivy.app import App
class MyGrid(GridLayout):
def __init___(self, **kwargs):
super(MyGrid, self).__init__(**kwargs)
self.cols = 2
self.add_widget(Label(text="Name: "))
self.name = TextInput(multiline=False)
self.add_widget(self.name)
self.add_widget(Label(text="Last Name: "))
self.lastname = TextInput(multiline=False)
self.add_widget(self.lastname)
self.add_widget(Label(text="Email: "))
self.email = TextInput(multiline=False)
self.add_widget(self.email)
class MyApp(App):
def build(self):
return MyGrid()
if __name__ == "__main__":
MyApp().run()
答案 0 :(得分:0)
在def __init___(self, **kwargs):
字之后的init
行上有一个额外的下划线。请删除它,然后它应该可以正常运行。