taurus-org / taurus

Moved to https://gitlab.com/taurus-org/taurus
http://taurus-scada.org
43 stars 46 forks source link

Some PoolMotorTV questions regarding labels and geometry #992

Closed TNoga0 closed 5 years ago

TNoga0 commented 5 years ago

Hello,

I was wondering if there is any possibility to: a) make the label (e.g. mot01 on the picture) not visible at all? Either a selected label or all of them at once, b) change the geometries of the LineEdit field or Abs/Rel ComboBox? I would like to make one a bit wider than the default, without resizing the whole window. Also, when I try to place a PoolMotorTV widget in a layout without TaurusFrame, it completely destroys the layout, for example: I would like to have a ComboBox and a PoolMotorTV object next to it in a horizontal layout, but rather than that, the PoolMotorTV object is being inserted in a separate "line", completely independent of my actions. Is it a typical behaviour? Is there any way to make those objects obedient without putting them in a TaurusForm?

Here is the picture for a) and b) : image

Regards, Tomasz Noga

cpascual commented 5 years ago

Hi @TNoga0,

a) make the label (e.g. mot01 on the picture) not visible at all?

PoolMotorTV is a sardana widget that inherits from the TaurusValue widget and heavily customizes it.

With regular TaurusValue widgets, it is possible to call setLabelWidgetClass with None. I tried with PoolMotorTV widget and in principle it also works (see 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)
    from sardana.taurus.qt.qtgui.extra_pool import PoolMotorTV
    form = TaurusForm()
    form.setCustomWidgetMap(
        {'SimuMotor': PoolMotorTV,
         'Motor': PoolMotorTV,
         'PseudoMotor': PoolMotorTV,
        }
    )
    form.setModel(['your/motor/modelname'])
    form[0].setLabelWidgetClass(None)  # <-- this does the trick
    form.show()
    sys.exit(app.exec_())

... but while this is ok for TaurusValue, I would not be surprised if the PoolMotorTV raised some issue when removing its label widget. If so, better file an issue in sardana, since it is a Sardana widget.

b) change the geometries of the LineEdit field or Abs/Rel ComboBox?

Not possible. See below:

Also, when I try to place a PoolMotorTV widget in a layout without TaurusFrame, it completely destroys the layout,

Yes, this is by design. See the following warning in the TaurusValue docs:

TaurusValue (and any derived class from it) should never be instantiated directly. It is designed to be instantiated by a TaurusForm class, since it breaks some conventions on the way it manages layouts of its parent model.

for example: I would like to have a ComboBox and a PoolMotorTV object next to it in a horizontal layout, but rather than that, the PoolMotorTV object is being inserted in a separate "line", completely independent of my actions. Is it a typical behaviour? Is there any way to make those objects obedient without putting them in a TaurusForm?

As I said, this is by design. The idea is precisely that the TaurusValue widgets will always have their labels aligned, with each other, their readwidgets aligned with each other, their write widgets aligned with each other, etc. ... and for this the TaurusValue needs to have control of the parent layout.

So, if you e.g. want to have a MyComboBoxClass instead of a the current label, in your first column, you may try to customize a PoolMotorTV (either by calling PoolMotorTV.setLabelWidgetClass(MyComboBoxClass) ) or by subclassing the PoolMotorTV and then registering your new subclass in the setCustomWidgetMap.

I hope this helps

PS: good luck with hacking the PoolMotorTV: IMHO, it is a "frankenstein" class that is in dire need of a refactoring :-/

cpascual commented 5 years ago

This has not seen movement in 19 days... so I assume it can be closed. @TNoga0 , feel free to reopen if there is something else.