Xy panels - z depth?

What I’m trying to do:
Im trying to make some cool looking components using the xypanel

What I’ve tried and what’s not working:
working so far but I don’t know how to move one component to the back or front

I believe that the components are listed in Z-order, from back to front, because add_component() always appends the new component (places it at the highest subscript) and shows it in front of all the others.

With that in mind, here’s an (untested) idea:

  1. Use get_components() to get the panel’s list of components.
  2. If this list is live, then rearranging this list would rearrange the components’ Z-orders.

The result would likely become visible the next time the panel gets redrawn, i.e., when the browser is idle.

Thanks for this :slight_smile:

How do I rearrange the components?clear and then add them again in the order required?

That would certainly work.

Note that if there is no other object referring to a component, then clearing the list would remove the only reference to it, so Python would then destroy that component. To avoid this, you might want to make a copy of the list, before you clear it. Then you can add from that list, in any order you like.

The (untested) shortcut I was referring to was to use Python’s native list support to rearrange the list in situ. I haven’t had a reason to try it, so far, so I don’t know whether it will work.

Yes, this is exactly the way!

1 Like

I need some assistance regarding z-values…how do you control this?
I have a form which I want to be non-responsive to input while a background-task works.
How can I add a component as overlay instead of it adding itself together with everything else?
Or are there better methods of making the GUI unresponsive and displaying information to the user during background-tasks?

This should really be raised as a new topic. But the short answer is, yes, there can be better ways. For example:

  1. Save the currently-open Form (object). (This is so that step 2 doesn’t destroy it, and step 3 can restore it.)
  2. Open a new Form with just the information you want to display, no interactive elements whatsoever. Then there’s nothing that the user can click on.
  3. When you’re done, make the saved Form the current one.
1 Like