-
Notifications
You must be signed in to change notification settings - Fork 46
Taurus eval using python variable defined in the current python module #745
Comments
Hi,
do you have any reason for not using:
w.setText(s)
?, or you didn't know about that possibility?.
This will work.
Regards,
Teresa
…On 04/27/18 10:21, almarass wrote:
Hi,
I tried to visualize in a TaurusLabel the content of a variable
defined in the current python module, but without success.
The code is as follows:
import sys
from taurus.external.qt import Qt
from taurus.qt.qtgui.application import TaurusApplication
app = TaurusApplication(sys.argv)
panel = Qt.QWidget()
layout = Qt.QHBoxLayout()
panel.setLayout(layout)
s = 'MAINTENANCE'
from taurus.qt.qtgui.display import TaurusLabel
w = TaurusLabel()
layout.addWidget(w)
w.model = 'eval:a=s1'
#w.model = ***@***.*** <https://github.com/self>.*/s1'
panel.show()
sys.exit(app.exec_())
The commented instruction was another attempt.
Is it somehow possible?
thanks
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#745>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFSqiOwoAdZx11jEhNAmSnmcx9_ElraSks5tstT2gaJpZM4Tp916>.
|
Hi,
the local variable has to be written via PyTango reading the string from a
DevEnum type attribute in order to bypass the problem that Taurus is not
ready to manage DevEnum type.
Could you suggest anything else?
thanks,
Alex
2018-04-27 10:34 GMT+02:00 teresanunez <notifications@github.com>:
… Hi,
do you have any reason for not using:
w.setText(s)
?, or you didn't know about that possibility?.
This will work.
Regards,
Teresa
On 04/27/18 10:21, almarass wrote:
>
> Hi,
> I tried to visualize in a TaurusLabel the content of a variable
> defined in the current python module, but without success.
> The code is as follows:
>
> import sys
> from taurus.external.qt import Qt
> from taurus.qt.qtgui.application import TaurusApplication
>
> app = TaurusApplication(sys.argv)
> panel = Qt.QWidget()
> layout = Qt.QHBoxLayout()
> panel.setLayout(layout)
>
> s = 'MAINTENANCE'
>
> from taurus.qt.qtgui.display import TaurusLabel
> w = TaurusLabel()
> layout.addWidget(w)
>
> w.model = 'eval:a=s1'
> #w.model = ***@***.*** <https://github.com/self>.*/s1'
>
> panel.show()
> sys.exit(app.exec_())
>
> The commented instruction was another attempt.
> Is it somehow possible?
>
> thanks
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <#745>, or mute the thread
> <https://github.com/notifications/unsubscribe-auth/
AFSqiOwoAdZx11jEhNAmSnmcx9_ElraSks5tstT2gaJpZM4Tp916>.
>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#745 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AXZERwdSoYZFljJorEbQzqMPvvgkwPcFks5tstgAgaJpZM4Tp916>
.
|
Hi @almarass , See the first example. If you need to do something more fancy, check the documentation Some examples:
|
Hi,
in the first example foo is explicitly given a value in the eval
instruction.
In my case I want to use a variable which has been previously defined in
the current python module, like:
foo = "something"
taurusform 'eval:a=foo;a'
Is it possible?
thanks
2018-04-27 10:57 GMT+02:00 Carlos Falcon <notifications@github.com>:
… Hi @almarass <https://github.com/almarass> ,
Yes, It can be done. Be aware of the PyTango limitation
<tango-controls/pytango#188>
See the first example. If you need to do something more fancy, check the
documentation
<http://taurus-scada.org/devel/api/taurus/core/evaluation.html>
Some examples:
taurusform 'eval:foo="hello";foo'
taurusform ***@***.****/foo=choice("abcd");foo'
taurusform 'eval:string="--> "+ {sys/tg_test/1/string_scalar};string'
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#745 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AXZER773atGmRKnJfOaYr9GWD6RHlL_9ks5tst1ugaJpZM4Tp916>
.
|
Hi @almarass,
|
I am not sure, but I think that the solution from #745 (comment) is not what @almarass is after, because it is static (the model is set to a string with the value of the variable at the moment of setting the model). If the module where the w.model = 'eval:@foo.*/s' BUT: when I tried I found that it does not work if used from the same module
import sys
from taurus.qt.qtgui.application import TaurusApplication
from taurus.qt.qtgui.display import TaurusLabel
app = TaurusApplication(sys.argv)
w = TaurusLabel()
w.model = 'eval:@foo.*/s'
w.show()
sys.exit(app.exec_())
s = "WHATEVER" |
In order to show the value of an enum attribute (dishmode), I tried the
following:
w = TaurusLabel()
layout.addWidget(w)
w.model =
'eval:a="{0}";a'.format(power_supply.attribute_query('dishMode').enum_labels[power_supply.read_attribute('dishMode').value])
panel.show()
given that:
power_supply = PyTango.DeviceProxy("//
151.97.17.82:10000/mid_dish_0001/elt/master")
It seems to work, but when the value of dishmode is changed, it does not
show the new value.
Is there any way to update it?
thanks
2018-04-30 11:51 GMT+02:00 Carlos Pascual <notifications@github.com>:
… I am not sure, but I think that the solution from #745 (comment)
<#745 (comment)>
is not what @almarass <https://github.com/almarass> is after, because it
is static (the model is set to a string with the value of the variable *at
the moment of setting the model*).
I understand that what @almarass <https://github.com/almarass> wants is
to be able to update the value of s and see the display updated.
If the module where the s variable is stored is called foo.py *and it is
in the python path*, the following *should* work:
w.model = ***@***.****/s'
*BUT*: when I tried I found that it does not work if do it from the *same*
module foo (it seems to get stuck). As a workaround, if you can use 2
modules:
- main.py
import sysfrom taurus.qt.qtgui.application import TaurusApplicationfrom taurus.qt.qtgui.display import TaurusLabel
app = TaurusApplication(sys.argv)
w = TaurusLabel()
w.model = ***@***.****/s'
w.show()
sys.exit(app.exec_())
- foo.py (note that this file must be in the python path!!!)
s = "WHATEVER"
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#745 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AXZER34rqG6rYarA4rCZlQnqyWRwRdrkks5ttt6WgaJpZM4Tp916>
.
|
This is because your code is essentially following the recipe from #745 (comment). Have a look at the alternative that I propose in #745 (comment) |
I followed the alternative proposed in #745 (comment), but it seems to behave in the same way (it does not update) |
Hi,
I tried to visualize in a TaurusLabel the content of a variable defined in the current python module, but without success.
The code is as follows:
The commented instruction was another attempt.
Is it somehow possible?
thanks
The text was updated successfully, but these errors were encountered: