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

Tried on main with pyside2.
Consider this code:
When
a_stringis the empty string (therefore False):Label(visible_when="a_string")does not get hiddenUItemwith the samevisible_when, and theLabel(visible_when="len(a_string)"), correctly do get hiddenTried on
mainwithpyside2.