【发布时间】:2016-07-24 22:08:03
【问题描述】:
我正在用 kivy 制作一个应用程序,在我的 kv 文件中,我有一个名为 MainScreen 的屏幕,它有两个 TextInput 框。当我按下按钮时,屏幕将变为 LoggedInScreen。如何将 MainScreen 上的 TextInput 框的输入传递给 LoggedInScreen,以便我可以将它们用作我在 main.py 中定义的函数的位置参数?这是我尝试过的(仅相关代码):
<LoggedInScreen>:
name: 'loggedin'
FloatLayout:
TextInput:
#This is not working
text: root.auth(MainScreen.ids.username.text, MainScreen.ids.password.txt)
font_name: 'PCBius.ttf'
background_color: (73/255,73/255,73/255,1)
keyboard_mode: 'managed'
readonly: True
size: 405, self.height
pos: 495,0
<MainScreen>:
name:'main'
FloatLayout:
TextInput:
id: username
multiline: False
size_hint: self.width/self.width/5, self.height/self.height/16
pos: 200,292
TextInput:
id: password
password: True
multiline: False
size_hint: self.width/self.width/5, self.height/self.height/16
pos: 200,232
但是它输出一个错误,说 MainScreen 没有定义。
感谢您的帮助!
【问题讨论】:
标签: python function class variables kivy