【发布时间】:2017-10-08 19:12:53
【问题描述】:
我正在尝试实现我使用 kivy 编写的游戏的图形部分。由于我是 kivy 的新手,因此我浏览了 ts 文档,其中找到了一些我研究和使用的编程示例。在其中一个示例中,我得到:
TypeError: object.__init__() takes no parameters
代码如下:
from kivy.app import App;
from kivy.uix.label import Label;
from kivy.uix.gridlayout import GridLayout;
from kivy.uix.textinput import TextInput;
class LoginScreen(GridLayout):
def __init__(self, **kwargs):
#super(LoginScreen, self).__new__(**kwargs) # == super(LoginScreen, self).__init__(**kwagrs)
#GridLayout.__init__()
super().__init__(**kwargs);
self.cols = 2 # The colors
# Creating the Object for username and then adding it into Canvans
self.add_widget(Label(text="Username: "))
self.username = TextInput(multiline=False)
self.add_widget(self.username)
# Creating the Object for password and then adding it into Canvans
self.add_widget(None,Label(Text="password:"))
self.password = TextInput(password=True,multiline=False)
self.add_widget(self.password)
class SimpleKivy(App):
def build(self):
return LoginScreen();
if __name__ == "__main__":
SimpleKivy().run();
【问题讨论】:
-
向我们展示产生错误的调用。输入是什么?您需要展示您所询问的问题。
-
@Chris Johnson 我工作正常,但将在凌晨 2 点完成。如果你有耐心,我回家后会更新帖子谢谢!
标签: python python-3.x kivy kivy-language