我正在try 使用KivyMD和Python制作一个基本的用户界面(我是初学者),但我有一些投标方面的问题.如果你们中有人能帮我,我将不胜感激.这是我的IDE返回给我的错误:
文件"C:\USERS\kaua.silva\Desktop\app_ig\app.kv",第67行,位于 ON_RELEASE:root.get_Text() ^^ 文件"kivy\weismproxy.pyx",第32行,在kivy.nedproxy.WeakProxy.getattr中. AttributeError:"FloatLayout"对象没有属性""Get_Text""
main.py file:个
from kivymd.tools.hotreload.app import MDApp
from kivy.lang import Builder
from kivy.core.window import Window
class App(MDApp):
def get_texts(self):
user_text_field = self.root.ids.username
user_text_field = user_text_field.text
password_text_field = self.root.ids.passoword
password_text_field = password_text_field.text
quantity_text_field = self.root.ids.quantity
quantity_text_field = quantity_text_field.text
return user_text_field, password_text_field, quantity_text_field
KV_FILES = ["app.kv"]
DEBUG = True
def build_app(self):
Window.size = (320, 370)
Window.resizable = 0
return Builder.load_file("app.kv")
App().run()
app.kv file:个
FloatLayout: #:kivy !
Image:
source: "src/images/instagram_bg.jpg"
allow_stretch: True
keep_ratio: False
MDLabel:
text: "Comment Bot"
color: "#FFFFFF"
font_size: "38sp"
font_name: "font.ttf"
pos_hint: {"center_x": 0.59, "center_y": 0.9}
MDIcon:
icon: "instagram"
color: "#FFFFFF"
font_size: "45sp"
pos_hint: {"center_x": 0.85, "center_y": 0.90}
MDTextField:
id: username
line_color_normal: "#ffffff"
line_color_focus: "#ffffff"
hint_text: "Nome de usuário ou e-mail"
size_hint_x: .8
pos_hint: {"center_x": 0.5, "center_y": 0.75}
mode: "rectangle"
hint_text_color_normal: "white"
hint_text_color_focus: "white"
text_color_focus: "#ffffff"
text_color_normal: "#ffffff"
font_size: "20sp"
MDTextField:
id: password
line_color_normal: "#ffffff"
line_color_focus: "#ffffff"
text_color: "#ffffff"
hint_text: "Senha"
size_hint_x: .8
pos_hint: {"center_x": 0.5, "center_y": 0.57}
mode: "rectangle"
hint_text_color_normal: "white"
hint_text_color_focus: "white"
text_color_focus: "#ffffff"
text_color_normal: "#ffffff"
font_size: "20sp"
MDTextField:
id: quantity
color_mode: "primary"
line_color_normal: "#ffffff"
line_color_focus: "#ffffff"
hint_text: "Quantidade de comentários"
size_hint_x: .8
pos_hint: {"center_x": 0.5, "center_y": 0.39}
mode: "rectangle"
hint_text_color_normal: "white"
hint_text_color_focus: "white"
text_color_focus: "#ffffff"
text_color_normal: "#ffffff"
font_size: "20sp"
MDRaisedButton:
text: "Iniciar"
theme_text_color: "Custom"
text_color: "#FFFFFF"
font_style: "Button"
md_bg_color: "#C8439C"
size_hint: .5, .13
pos_hint: {"center_x": .5, "center_y": .155}
font_size: "16sp"
on_release: root.get_texts()
我想用MDRaisedButton绑定函数GET_TEXTS(它只是一个简单的函数,我将用另一个函数替换它),但vscode无法识别该函数.谢谢你的到来!