import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
class MyGrid(GridLayout):
def __int__(self, **kwargs):
super(MyGrid, self).__init__(**kwargs)
self.cols= 1
self.inside= GridLayout()
self.inside.cols= 2
self.inside.add_widget(Label(text='Pan Card No: '))
self.pan= TextInput(multiline= FALSE)
self.inside.add_widget(self.pan)
self.inside.add_widget(Label(text='Aadhar Card No: '))
self.aadhar= TextInput(multiline= FALSE)
self.inside.add_widget(self.aadhar)
self.inside.add_widget(Label(text='Phone No: '))
self.phoneno= TextInput(multiline= FALSE)
self.inside.add_widget(self.phoneno)
self.add_widget(self.inside)
self.submit= Button(text='Submit', font_size=40)
self.submit.bind(on_press=self.pressed)
self.add_widget(self.submit)
def pressed(self, instance):
pan=self.pan.text
aadhar=self.aadhar.text
phoneno=self.phoneno.text
class MyApp(App):
def build(self):
return MyGrid()
if __name__== "__main__":
MyApp().run()
对于我上面的代码,运行Kivy时出现黑屏。几分钟前,它运行良好,并在我添加了按下的功能后突然开始显示黑屏。 使用VSCode在Python 3.8.2上使用Kivy [base]。请告诉我为什么会发生
答案 0 :(得分:1)
拼写错误。更改:
def __int__(self, **kwargs):
收件人:
def __init__(self, **kwargs):