taurus-org / taurus

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

Improve set formatter dialog #1039

Closed cmft closed 4 years ago

cmft commented 4 years ago

Fixes #1035

cmft commented 4 years ago

Done

cpascual commented 4 years ago

I did some heavy refactoring. Can some @taurus-org/integrators test it?

Here is a snippet of a code that can be used to test:

from taurus.qt.qtgui.application import TaurusApplication
from taurus.qt.qtgui.panel import TaurusForm
import taurus

def myformatter(*a, **kw):
    return "**{1.2e}**"

if __name__ == '__main__':
    import sys
    app = TaurusApplication(cmd_line_parser=None)
    w = TaurusForm()
    w.setModifiableByUser(True)
    model = ['sys/tg_test/1/float_scalar', 'sys/tg_test/1/double_scalar']
    w.setModel(model)
    w.show()

    from taurus.core.tango.util import tangoFormatter
    # w[0].setFormat(tangoFormatter)
    # w[0].setFormat('taurus.core.tango.util.tangoFormatter')
    # w[0].setFormat(myformatter)
    w[0].setFormat('///{:1.2f}///')

    # show setFormatter dialog
    w[0].onSetFormatter()
    sys.exit(app.exec_())

I just see one thing missing: if the selected formatter happens to be None (which is often the case for the class formatter), onSetFormatter does not set it. This requires either deprecating the onSetFormatter/showFormatterDlg API or breaking it. I do not expect anyone having reimplemented these methods in their own code, so I vote for breaking in this corner case UPDATE: this is taken care of in cf9be81

cpascual commented 4 years ago

mmm... I clearly broke the formatters with my refactoring... I'll investigate and fix

cpascual commented 4 years ago

All clear now. Merging