我不明白为什么在运行代码时会出现这种类型的错误。我已经检查了几次,一切似乎都很好,但是代码仍然不想运行。
这是我的__main__.py
文件:
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.anchorlayout import AnchorLayout
from kivy.properties import ObjectProperty # at top of file
class AccountDetailsForm(AnchorLayout):
server_box = ObjectProperty()
username_box = ObjectProperty()
password_box = ObjectProperty()
def login(self):
print(self.server_box.text)
print(self.username_box.text)
print(self.password_box.text)
class Orkiv(App):
pass
Orkiv().run()
这是我的orkiv.kv
文件:
AccountDetailsForm:
<AccountDetailsForm>:
anchor_y: "top"
server_box: server_input
username_box: username_input
password_box: password_input
BoxLayout:
orientation: "vertical"
height: "200dp"
size_hint_y: None
GridLayout:
cols: 2
row_default_height: "40dp"
row_force_default: True
spacing: "10dp"
padding: "10dp"
Label:
text: "Server" //THE ERROR SEEMS TO HAPPEN HERE
AccountDetailsTextInput:
id: server_input
Label:
text: "Username"
AccountDetailsTextInput:
id: username_input
Label:
text: "Password"
AccountDetailsTextInput:
password: True
id: password_input
Button:
size_hint_y: None
height: "40dp"
text: "Login"
on_press: root.login()
有任何想法吗 ?谢谢。
在您的orkiv.kv
文件中,将其更改AccountDetailsTextInput
为just TextInput
。
AccountDetailsForm:
<AccountDetailsForm>:
anchor_y: "top"
server_box: server_input
username_box: username_input
password_box: password_input
BoxLayout:
orientation: "vertical"
height: "200dp"
size_hint_y: None
GridLayout:
cols: 2
row_default_height: "40dp"
row_force_default: True
spacing: "10dp"
padding: "10dp"
Label:
text: "Server"
TextInput:
id: server_input
Label:
text: "Username"
TextInput:
id: username_input
Label:
text: "Password"
TextInput:
password: True
id: password_input
Button:
size_hint_y: None
height: "40dp"
text: "Login"
on_press: root.login()
该应用程序应运行。请参阅下面的输出。
让我们知道是否有帮助。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句