diff --git a/tryton/tryton/common/common.py b/tryton/tryton/common/common.py index c3de490ebdd..2e50e30261f 100644 --- a/tryton/tryton/common/common.py +++ b/tryton/tryton/common/common.py @@ -1461,13 +1461,12 @@ def ellipsize(string, length): def get_align(float_, expand=True): "Convert float align into Gtk.Align" value = float(float_) + if expand: + return Gtk.Align.FILL if value < 0.5: return Gtk.Align.START elif value == 0.5: - if expand: - return Gtk.Align.FILL - else: - return Gtk.Align.CENTER + return Gtk.Align.CENTER else: return Gtk.Align.END diff --git a/tryton/tryton/gui/window/view_form/view/form.py b/tryton/tryton/gui/window/view_form/view/form.py index 0f314fc4cce..d9f9502bf53 100644 --- a/tryton/tryton/gui/window/view_form/view/form.py +++ b/tryton/tryton/gui/window/view_form/view/form.py @@ -287,13 +287,18 @@ def _parse_separator(self, node, attributes): return vbox = VBox(attrs=attributes) if attributes.get('string'): + attributes.setdefault('xexpand', 0) + attributes.setdefault('xalign', 0) + attributes.setdefault('yalign', 0.5) label = Label(label=attributes['string'], attrs=attributes) label.set_halign(get_align( - attributes.get('xalign', 0.0), - bool(attributes.get('xexpand', True)))) + attributes['xalign'], + bool(attributes.get('xexpand')))) label.set_valign(get_align( - attributes.get('yalign', 0.5), - bool(attributes.get('yexpand', False)))) + attributes['yalign'], + bool(attributes.get('yexpand')))) + label.props.xalign = float(attributes['xalign']) + label.props.yalign = float(attributes['yalign']) vbox.pack_start(label, expand=True, fill=True, padding=0) self.view.state_widgets.append(label) if name: @@ -311,13 +316,17 @@ def _parse_label(self, node, attributes): attributes['xalign'] = 0.0 attributes.setdefault('xexpand', 0) + attributes.setdefault('xalign', 1) + attributes.setdefault('yalign', 0.5) label = Label(label=attributes.get('string', ''), attrs=attributes) label.set_halign(get_align( - attributes.get('xalign', 1.0), + attributes['xalign'], bool(attributes.get('xexpand')))) label.set_valign(get_align( attributes.get('yalign', 0.5), bool(attributes.get('yexpand')))) + label.props.xalign = float(attributes['xalign']) + label.props.yalign = float(attributes['yalign']) label.set_angle(int(attributes.get('angle', 0))) self.view.state_widgets.append(label) self.container.add(label, attributes)