Closed canismarko closed 1 week ago
Thank you for catching this, the explanation and the proposed fix both make sense to me. I'm happy to accept a PR or I'll make one myself in a bit (I happen to be working on typhos things this week)
Sorry for the delay on getting back to these- I have a short vacation now and then next week these two tickets are reaching the top of my typhos todo list.
No worries. I'd have submitted a PR by now myself except we're bringing our beamline back up right now after APS-U. Thanks.
Expected Behavior
During initialization, a new
pcdsdevices.plugins.core.SignalConnection
object should set the enum_choices (really all metadata) first, then set the signal's value so that it can select from the available choices.Current Behavior
When the
PyDMEnumComboBox
first loads, there is an error message from PyDM:Can not change value to 'nA'. Not an option in PyDMComboBox
even though when I look at the widget, "nA" is one of the options. This happens regardless of what the enum_choices actually are.
I think this is because the
SignalConnection.add_listener
method first callsself.send_new_value(signal_val)
thenself.send_new_meta(**signal_meta)
.After the widget is shown, If I change the signal's value outside of PyDM (e.g. though channel access), then the widget updates properly.
Possible Solution
Reversing the order of
self.send_new_value(…)
andself.send_new_meta(…)
fixes this problem at my beamline.I'm happy to prepare a PR that fixes this.
Steps to Reproduce (for bugs)
EpicsSignal
obj with enum choicesContext
I have several windows that use this pattern. Right now, we get incorrect values shown in the PyDMEnumComboBox when it first loads. This makes it difficult to use, since we first have to wait for the PV to change some other way (or force it to change somehow). It'd be nice if it showed the correct value from the beginning.
Your Environment
Here are the list of installed packages I'm using: https://gist.github.com/canismarko/4f681511b295451179b421a14ba0566e
Running in a conda environment on a RHEL9 computer.