Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions tryton/tryton/common/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 14 additions & 5 deletions tryton/tryton/gui/window/view_form/view/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down