Skip to content

LineEdit: enforce explicit disable

Carlos Pascual requested to merge github/fork/cpascual/taurusLE-disable into develop

TaurusValueLineEdit auto enables/disables itself based based on events. This precludes the user from explicitly disable it. Fix by avoiding reenabling if setEnabled(False) is called. Note that auto-disabling on errors is still allowed even if setEnabled(True) is called, since the widget is not usable in case of error.

To test this you can use the following snippet (without this PR, the second widget will start disabled but will be autoenabled on the first change event, while with this PR it will stay disabled even if changes are forced with the first widget):

from taurus.qt.qtgui.application import TaurusApplication
from taurus.qt.qtgui.input import TaurusValueLineEdit
from taurus.external.qt import Qt


if __name__ == "__main__":
    import sys
    app = TaurusApplication(cmd_line_parser=None)

    w = Qt.QWidget()
    ly = Qt.QVBoxLayout()
    w.setLayout(ly)
    model = "sys/tg_test/1/short_scalar"

    e1 = TaurusValueLineEdit()
    e1.setModel(model)
    ly.addWidget(e1)

    e2 = TaurusValueLineEdit()
    e2.setModel(model)
    ly.addWidget(e2)
    e2.setEnabled(False)

    w.show()

    sys.exit(app.exec_())

Merge request reports