【问题标题】:Kivi, resizing button in layout fileKivi,在布局文件中调整按钮大小
【发布时间】:2021-07-29 15:55:36
【问题描述】:

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

        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"

【问题讨论】:

    标签: python kivy widget


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-11
      • 2015-08-16
      • 2012-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多