Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

visible_when on Label doesn't implicitly take the boolean of the specified trait #1768

Closed
nicolasap-dm opened this issue Nov 1, 2021 · 0 comments · Fixed by #1769
Closed
Milestone

Comments

@nicolasap-dm
Copy link
Contributor

Consider this code:

from traits.api import HasTraits, Str
from traitsui.api import View, Item, Label, UItem

class Foo(HasTraits):

    a_string = Str()
    fixed_string = Str("a_string is true (according to UItem)")

    traits_view = View(
        Item("a_string"),
        Label("a_string is true (according to Label)", visible_when="a_string"),
        UItem("fixed_string", style="readonly", visible_when="a_string"),
        Label("len(a_string) is nonzero (according to Label)", visible_when="len(a_string)"),
        width=420, height=200
    )

Foo().configure_traits()

When a_string is the empty string (therefore False):

  • the Label(visible_when="a_string") does not get hidden
  • for comparison, the UItem with the same visible_when, and the Label(visible_when="len(a_string)"), correctly do get hidden

Peek 2021-11-01 11-13

Tried on main with pyside2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants