taurus-org / taurus

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

TaurusForm width cannot be reduced if displaying a long text (trimming not triggered) #1142

Open cpascual opened 3 years ago

cpascual commented 3 years ago

TaurusLabel auto-trims its text in order to accommodate long texts if the width given to the widget is small.

This can be seen when reducing the size of the label from the following snippet (it correctly trims):

from taurus.qt.qtgui.application import TaurusApplication
from taurus.qt.qtgui.display import TaurusLabel
import sys

app = TaurusApplication(cmd_line_parser=None)
w = TaurusLabel()
w.setModel("eval:long='A l{}ng string'.format('o'*60);long")
w.show()
sys.exit(app.exec_())

But if the label is within a form which started with a large enough size, its trimming mechanism won't be triggered even if the user tries to resize the form.

It can be reproduced by trying to reduce the width of the following form:

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

app = TaurusApplication(cmd_line_parser=None)
w = TaurusForm()
w.setModel(["eval:long='A l{}ng string'.format('o'*60);long"])
w.show()
sys.exit(app.exec_())
cpascual commented 3 years ago

Note that the problem is in the TaurusForm widget, not the label one, because even if one sets the readWidgetClass to None (w[0].setReadWidgetClass(None)) after having initialized the form, this can't be downsized

cpascual commented 3 years ago

On the other hand, note that if you make the text much longer (e.g. by replacing the hardcoded 60 by 600), then the form will initialize with the label already trimmed and therefore it can be resized !