Skip to content

MNT: establish a deterministic designer widget order#1325

Open
ZLLentz wants to merge 2 commits intoslaclab:masterfrom
ZLLentz:mnt_designer_widget_order
Open

MNT: establish a deterministic designer widget order#1325
ZLLentz wants to merge 2 commits intoslaclab:masterfrom
ZLLentz:mnt_designer_widget_order

Conversation

@ZLLentz
Copy link
Copy Markdown
Member

@ZLLentz ZLLentz commented Apr 17, 2026

In this PR, I'm looking for:

  • Is this a good idea?
  • Is this the correct order?
  • Is the implementation OK?

Problem Statement

The PyDM widget order in designer is currently chaotic. I didn't notice this until I started adding some custom widget categories and got very confused about the ordering, then investigated how the ordering is established, and then finally decided that the only way to handle it was to either patch PyDM or make my own designer plugin loader. If others think this is useful I'd prefer to do it in PyDM itself.

Background

Here's a quick primer about how the ordering of the widgets is determined:

  • Select widgets one by one in order, different by qt wrapper:
    • in pyqt5: by the order in globals(), which is the order in which each widget's attr name in the module is first introduced, via import or otherwise
    • in pyside6: presumably, by the order we pass the widgets to addCustomWidget (I haven't tested pyside6). Note that currently in pydm this also ends up being essentially the import/plugin creation order.
  • Add this widget to the bottom of an existing group, or start a new group if needed
  • Do no sorting at all

So this leads to funny things like PyDMNTTable being the first input widget and PyDMTabWidget being the first container widget, simply because their names are early in globals() due to the imports and attribute name re-use, while other widgets are ordered somewhat deliberately. Small permutations to the ordering in these files can chaotically interfere with the overall designer ordering.

image

It also leads to nonsense ordering for entrypoint widget groups:

image

This ends up depending on the order in which the widgets are loaded from the entrypoint, which to my eye seems to always be sorted by widget name. So the first group is the group associated with a widget that starts with A, and so-on.

This PR

This PR simply creates an opinionated ordering of the designer widgets:

  1. All the pydm widgets, in the current category orders that people are used to, which roughly tracks how the built-in widgets are sorted.
  2. Pydm widgets sorted by name within each category
  3. Entrypoint widgets sorted by group name, then by name

The details can be changed as much as we like.

I tried to change as little as possible unrelated to this PR- if you'd like me to change more, let me know.

Notes about conda

The conda-forge build uses the internal widgets submodule to set up the designer plugins and would need to be changed to use the proper top-level file.

https://github.com/conda-forge/pydm-feedstock/blob/main/recipe/build.sh#L15

@jbellister-slac
Copy link
Copy Markdown
Collaborator

I definitely think this is a good idea. I'd never really noticed the ordering before either. I think the order you've gone with makes sense, and would be happy to go with this as is with this implementation which works fine with my testing.

And good point about the conda-forge build, we could just go ahead and update that now, it should have been using this already anyway:

https://github.com/slaclab/pydm/blob/master/conda-recipe/build.sh

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 this pull request may close these issues.

2 participants