From cc11b151feb85df21e25a2ec158e1df2d17f89f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 16 Nov 2019 12:54:07 +0100 Subject: [PATCH] Set alignment on widget and do not override with [x,y]fill The alignment and fill properties are merged in GTK3 and the default value is FILL. Also using properties in Gtk.Align is deprecated so it is better to set directly alignment on the widget. issue8799 review278121002 --- tryton/gui/window/view_form/view/form.py | 11 ++++------- .../window/view_form/view/form_gtk/state_widget.py | 13 ------------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/tryton/gui/window/view_form/view/form.py b/tryton/gui/window/view_form/view/form.py index 7ab729a36d..d741b826a6 100644 --- a/tryton/gui/window/view_form/view/form.py +++ b/tryton/gui/window/view_form/view/form.py @@ -34,7 +34,7 @@ from .form_gtk.dictionary import DictWidget from .form_gtk.multiselection import MultiSelection from .form_gtk.pyson import PYSON from .form_gtk.state_widget import (Label, VBox, Image, Frame, ScrolledWindow, - Notebook, Alignment, Expander) + Notebook, Expander) _ = gettext.gettext @@ -91,12 +91,7 @@ class Container(object): return widget.set_vexpand(bool(attributes.get('yexpand'))) - if attributes.get('yfill'): - widget.set_valign(Gtk.Align.FILL) - widget.set_hexpand(bool(attributes.get('xexpand', True))) - if attributes.get('xfill', True): - widget.set_valign(Gtk.Align.FILL) if attributes.get('help'): self.tooltips.set_tip(widget, attributes['help']) @@ -227,7 +222,9 @@ class FormXMLViewParser(XMLViewParser): int(attributes.get('width', -1)), int(attributes.get('height', -1))) - self.container.add(Alignment(widget.widget, attributes), attributes) + widget.widget.set_halign(get_align(attributes.get('xalign', 0.5))) + widget.widget.set_valign(get_align(attributes.get('yalign', 0.5))) + self.container.add(widget.widget, attributes) if name in self._mnemonics and widget.mnemonic_widget: label = self._mnemonics.pop(name) diff --git a/tryton/gui/window/view_form/view/form_gtk/state_widget.py b/tryton/gui/window/view_form/view/form_gtk/state_widget.py index 1e4468048b..49be6b6ea2 100644 --- a/tryton/gui/window/view_form/view/form_gtk/state_widget.py +++ b/tryton/gui/window/view_form/view/form_gtk/state_widget.py @@ -98,19 +98,6 @@ class Notebook(StateMixin, Gtk.Notebook): widget._readonly_set(True) -class Alignment(Gtk.Alignment): - - def __init__(self, widget, attrs): - super(Alignment, self).__init__() - self.props.xalign = float(attrs.get('xalign', 0.0)) - self.props.yalign = float(attrs.get('yalign', 0.5)) - self.props.xscale = float(attrs.get('xexpand', 1.0)) - self.props.yscale = float(attrs.get('yexpand', 1.0)) - self.add(widget) - widget.connect('show', lambda *a: self.show()) - widget.connect('hide', lambda *a: self.hide()) - - class Expander(StateMixin, Gtk.Expander): def __init__(self, label=None, attrs=None):