Complex boolean expressions with .rx

Say I have

j = panel.rx(False)
k = panel.rx(False)
l = panel.rx(False)
u = panel.rx(False)

I want to do something like

b = panel.widgets.Button()
b.disabled = (j or k) and (l or u)

Is that possible with panel.rx?

I think so if you chain them like j.rx.or_(k) Reactive Functions and Expressions — param v2.2.1

But it could get pretty ugly and it’s probably better to use pn.bind instead?

For ref:

1 Like

So j.rx.or_(k) gives (j | k) part and I can do l.rx.or_(u) for (l or u) part, but my question is how do I apply and to these two afterwards? If I did:

j.rx.or_(k).rx.and_(l.rx.or_(u))

wouldn’t that give me this instead?

j or (k and (l or u))

With panel.bind, it would work like this, right?

j = panel.rx(False)
k = panel.rx(False)
l = panel.rx(False)
u = panel.rx(False)

b = panel.widgets.Button()
b.disabled = pn.bind(lambda j, k, l, u: (j or k) and (l or u), j, k, l, u)