微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Kivi,在布局文件中调整按钮大小

如何解决Kivi,在布局文件中调整按钮大小

在我的代码中,我在用户登录时调整大小并尝试隐藏按钮。问题是登录按钮由于未知原因没有正确响应。

        Label:
            halign: 'center'
            valign: 'middle'
            text_size: self.size
            size_hint_x: .5
            text: root.text
        PrimaryButton:
            text: "Manage" if (root.text != '') else ""
            size_hint_x: .25 if (root.text != '') else 0
            opacity: 1 if (root.text != '') else 0
            disabled: False if (root.text != '') else True
            on_release:
                root.logout() if (root.text != '') else root.changeScreen("AccountCreation")
                root.manager.transition.direction = "down"
        PrimaryButton:
            text: "Log Out" if (root.text != '') else "Log In"
            size_hint_x: .25 if (root.text != '') else .5
            on_release:
                root.logout() if (root.text != '') else root.changeScreen("AccountCreation")
                root.manager.transition.direction = "down"

Not logged in

Logged in

解决方法

想通了,第一个按钮应该有这个参数-

size_hint: (.25,1) if (root.text != '') else (None,1)

宽度:0 if (root.text != '') else 0

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。