我正在尝试制作一个表单应用程序,但我不理解该错误:
Instead of:
<uses-permission android:name="{applicationId}.permission.MAPS_RECEIVE" />
<permission
android:name="{applicationId}.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
Used:
<uses-permission android:name="com.complete.appicationID.permission.MAPS_RECEIVE" />
<permission
android:name="com.complete.appicationID.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
此处提供代码;
TypeError: object.__init__() takes exactly one argument (the instance to initialize)
class Myapp(App):
def build(self):
return Grid1()
class Grid1(GridLayout):
def __init__(self,**kwargs):
super(Grid1,self).__init__(**kwargs)
self.cols=1
self.inside=GridLayout()
self.inside.cols=2
self.inside.add_widget(Label(text="Your name is :"))
self.name=TextInput(multiline=False)
self.inside.add_widget(self.name)
self.inside.add_widget(Label(text="Your Last name is :"))
self.lastname=TextInput(multiline=False)
self.inside.add_widget(self.lastname)
self.inside.add_widget(Label(text="Your email is :"))
self.email=TextInput(multiline=False)
self.inside.add_widget(self.email)
self.submit=Button(text="Submit",font=40)
self.add_widget(self.submit)
if __name__=="__main__":
Myapp().run()
答案 0 :(得分:2)
好吧,错误地不在您的super(Grid1,self).__init__(**kwargs)
中,该错误在于您创建按钮。您做到了:
self.submit = Button(text="Submit", font=40)
self.add_widget(self.submit)
但是正如docs所说,字体大小是由 font_size 而不是 font 设置的。该代码应为:
self.submit = Button(text="Submit", font_size=40)
self.add_widget(self.submit)
这应该很好。
只想感谢@chepner指出这一点:
请注意,问题在于字体无法被 按钮(或其他任何按钮)只是沿链向上传递,直到 最终传递给
object.__init__
(这会引发错误 简单地忽略意外的参数。