我在登录屏幕上添加了一个复选框,用于保存用户名和密码信息,这样用户就不必每次都输入它们。我考虑过创建一个文本文件来存储这些信息,但也许有更好的方法。我无法正确保存它;这就是我到目前为止所拥有的。在我的类的 init 方法中,我正在检查是否有包含信息的文本文件。如果是这样,我想提取用户名和密码来填写我屏幕上的 TextInputs。如果没有,我将它们留空,让用户填写两个 TextInput。Textinputs 在我的下一个方法 add_user() 中处理。我得到这个错误:AttributeError: 'super' object has no attribute '__getattr__'。我还没有弄清楚复选框的行为,因为我已经出错了。有人有想法吗?try.pyclass SigninWindows(Screen): def __init__(self, **kwargs): super().__init__(**kwargs) if os.path.isfile('prev_details.txt'): with open('prev_details.txt', 'r') as f: d = f.read().split(',') self.ids.username_field.text = d[0] self.ids.pwd_field.text = d[1] else: self.ids.username_field.text = '' self.ids.pwd_field.text = '' def add_user(self): uname = self.ids.username_field.text passw = self.ids.pwd_field.text info = self.ids.info table_name = uname.replace('@', '_').replace('.', '_')try.kv<SigninWindows>: id: signin_page name: "signin_page" orientation: "vertical" spacing: 10 space_x: self.size[0]/5.5 canvas.before: Color: rgba: (0,0,0,1) Rectangle: size: self.size pos: self.pos BoxLayout: id: data_signin orientation: 'vertical' size_hint_x: 1 BoxLayout: Image: id: ds_im orientation: 'vertical' source: 'ds.png' allow_stretch: True BoxLayout: id: validate_info orientation: "vertical" size_hint: 1,0.8 padding: 80, 10 Label: id: info text: '' markup: True
添加回答
举报
0/150
提交
取消