Open marouanebj opened 4 years ago
Hi, For TaurusLabel:
I managed to do it in the GUI Code for the TaurusLabel, using the precision.
I also found the setFormat but I do not know how to write a format so I guessed from the code,
and self.positionTaurusLabel.setFormat('{:.3f}')
added the dimensionless text so it gave me:
"52.123 dimensionless".
Is there a way with format to not have the dimensionless written?
For TaurusWheelEdit:
None of the solutions worked precision nor setFormat
here after my current code
self.positionTaurusLabel = TaurusLabel(self)
# self.positionTaurusLabel.setFormat('{:.3f}')
self.positionTaurusLabel.setModel(model + "/position")
self.positionTaurusLabel.modelObj.precision = 3
self.positionTaurusLabel.setBgRole('parentObj.stateObj.rvalue')
self.positionTaurusWheelEdit = TaurusWheelEdit(self)
self.positionTaurusWheelEdit.setModel(model + "/position")
# self.positionTaurusWheelEdit.modelObj.precision = 3
I just see one problem here when I use self.positionTaurusLabel.modelObj.precision = 3
if the Sardana server is OFF when I start the GUI it does not work.
For the TaurusWheelEdit I use
self.positionTaurusWheelEdit.setModel(model + "/position")
self.positionTaurusWheelEdit.setDigitCount(3, 3)
and i have the same pb if the Sardana server is OFF when I start the GUI it does not work. the setModel does reset the stuff i guess
Hi, first just the obvious question: since you are using sardana, have you considered just using a PoolMotorTV in a TaurusForm?
Hi, first just the obvious question: since you are using sardana, have you considered just using a PoolMotorTV in a TaurusForm?
I'm using an old version 2.6.2 of Sardana I know I should move to new one and I do not know if PoolMotorTV is there and how to use it. The problem is that there are to much layers to understand I have to dig a lot more to make my GUI. So I code in Python my Qt GUI with Taurus and with Sardana I code my Controllers. Using the taurusdesigner does not work for me when I want to tune my GUI Its always hard. Thanks
Now, to reply your questions:
Regarding how to remove the "dimensionless": since https://github.com/hgrecco/pint/pull/303 was integrated in pint, the "abbreviation" for "dimensionless" is an empty string. Therefore it is just a matter of using the "~" char in the format to tell pint to use the abbreviated unit (taurus does this by default, but you need to do it explicitly if you set your own format).
So, just use '{:~.3f}'
as your format.
If by any chance you are using a very old pint, then you can work around this by using:
'{0.magnitude:.3f}
See the following snippet as a demo:
from taurus.qt.qtgui.application import TaurusApplication
from taurus.qt.qtgui.display import TaurusLabel
if __name__ == "__main__":
import sys
app = TaurusApplication(cmd_line_parser=None)
w = TaurusLabel()
# w.setFormat('{:.1f}') # <-- with this it shows "dimensionless"
# w.setFormat('{0.magnitude:.1f}') # <-- with this it does not, but it is ugly
w.setFormat('{:~.1f}') # <-- this does the trick too and is more robust
w.setModel("eval:Q(123.456)")
w.show()
w.resize(200, 50)
sys.exit(app.exec_())
I'm using an old version 2.6.2 of Sardana I know I should move to new one and I do not know if PoolMotorTV is there and how to use it. The problem is that there are to much layers to understand I have to dig a lot more to make my GUI. So I code in Python my Qt GUI with Taurus and with Sardana I code my Controllers. Using the taurusdesigner does not work for me when I want to tune my GUI Its always hard. Thanks
The PoolMotorTV is also available in sardana 2.x
My recommendation (unless you are using the latest taurus from develop, in which case, see #1108 ) is that you do something like the following snippet:
from taurus.qt.qtgui.application import TaurusApplication
from taurus.qt.qtgui.panel import TaurusForm
if __name__ == "__main__":
import sys
app = TaurusApplication(cmd_line_parser=None)
w = TaurusForm()
cwmap = {
'SimuMotor': ('sardana.taurus.qt.qtgui.extra_pool.PoolMotorTV', (), {}),
'Motor': ('sardana.taurus.qt.qtgui.extra_pool.PoolMotorTV', (), {}),
'PseudoMotor': ('sardana.taurus.qt.qtgui.extra_pool.PoolMotorTV', (), {}),
'PseudoCounter': ('sardana.taurus.qt.qtgui.extra_pool.PoolChannelTV', (), {}),
'CTExpChannel': ('sardana.taurus.qt.qtgui.extra_pool.PoolChannelTV', (), {}),
'ZeroDExpChannel': ('sardana.taurus.qt.qtgui.extra_pool.PoolChannelTV', (), {}),
'OneDExpChannel': ('sardana.taurus.qt.qtgui.extra_pool.PoolChannelTV', (), {}),
'TwoDExpChannel': ('sardana.taurus.qt.qtgui.extra_pool.PoolChannelTV', (), {}),
'IORegister': ('sardana.taurus.qt.qtgui.extra_pool.PoolIORegisterTV', (), {}),
}
w.setCustomWidgetMap(cwmap)
w.setModel(['your/poolmotor/device']) # <--put your motor **device** name here
w.show()
sys.exit(app.exec_())
I just see one problem here when I use
self.positionTaurusLabel.modelObj.precision = 3
This is monkey-patching and as such is expected not to work in many situations.
and i have the same pb if the Sardana server is OFF when I start the GUI it does not work. the setModel does reset the stuff i guess
... like this one, for the reason that you mention ;-)
Thanks a lot for the infos and the Format that worked. I might try the TaurusForm that you send me if I find some time.
If you have an idea for the Digits I would be happy to here it.
self.positionTaurusWheelEdit.setDigitCount(3, 3) # does not work when Sardana server restart
And the unit too. Do you think I should ask in the github sardana issues or it is ok here.
Thanks Again.
Sorry @marouanebj , I missed the last question, and just saw it now.
If you have an idea for the Digits I would be happy to here it. self.positionTaurusWheelEdit.setDigitCount(3, 3) # does not work when Sardana server restart And the unit too.
I haven't looked at it in detail, and maybe the behavior that you describe is actually a bug in the Wheel Edit. If you think so, could you please create a snippet with a simple demo?
In any case you can probably work around the issues by subclassing the wheel edit widget to force your desired settings after setModel
Do you think I should ask in the github sardana issues or it is ok here.
For "pure taurus"-related widgets it is fine here. If you have questions regarding PoolMotorTV
and alike, then the sardana issues tracker is the right place
Hello,
I want to display the position of a motor with TaurusLabel and control it with TaurusWheelEdit. I want to see a precision of 3 (exemple: 50.123) but I see only 2.
I have my Sardana MotorController, and I see the position perfectly using spock.
Here after the description of what Info I managed to get using spock. I see format, format_spec, precision but I have no clue how to set these.
I did not find how to set the format, and also the Unit.
I'm still with python-taurus/stable,now 4.5.0+dfsg-1 all [installé].
Do I have to do it in the Sardana Controller, if yes how ? Can I do it in the GUI code ?
Thanks, Marouane