from kivy.properties import ObjectProperty
from kivy.uix.floatlayout import FloatLayout
from kivymd.app import MDApp
from kivymd.uix.screen import Screen
from kivy.lang import Builder
from Help import help
from kivymd.uix.dialog import MDDialog
class Begins(MDApp):
def build(self):
self.theme_cls.primary_palette = "Yellow"
self.theme_cls.primary_hue = "A700"
self.theme_cls.theme_style = "Dark"
screen = Screen()
self.id_v = Builder.load_string(help)
screen.add_widget(self.id_v)
return screen
class My(FloatLayout):
scr = ObjectProperty(None)
def data(self):
username = self.id_v.user.text
password = self.id_v.passw.text
if username == "MD" and password == "kivy":
print('ok')
else:
dial=MDDialog(text='Opps Wrong!')
dial.open()
Begins().run()
ここに私のkivyファイルがあります
help = """
Screen:
id:scr
user:user
passw:passw
FloatLayout:
MDTextField:
id: user
hint_text : "Enter your Name"
helper_text : "Have u forget it?"
helper_text_mode : "on_focus"
icon_right : "android"
icon_right_color : app.theme_cls.primary_color
size_hint_x :None
width : '300'
pos_hint:{'center_x':0.5,'center_y':0.6}
MDTextField:
id: passw
hint_text : "Enter your Password"
helper_text : "Got it?"
helper_text_mode : "on_focus"
icon_right : "key"
icon_right_color : app.theme_cls.primary_color
size_hint_x :None
width : '300'
pos_hint:{'center_x':0.5,'center_y':0.5}
pass: True
MDRectangleFlatButton:
text:"Log in"
pos_hint:{'center_x': 0.5, 'center_y': 0.4}
on_release:root.data()
"""
AttributeError: ' Screen ' オブジェクトに属性 'data' がありません。 :この画面をログインボタンとして使用しています。