From ae520344dcfd69fcb6ee00cc69b8303e29ec5f7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 28 Aug 2015 10:57:15 +0200 Subject: [PATCH] Change Progressbar to work with float between 0 and 1 issue4929 review16561002 --- CHANGELOG | 1 + .../window/view_form/view/form_gtk/progressbar.py | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ae2f955606..06a6a8ef6a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Change Progressbar to work with float between 0 and 1 * Add Fast Tabbing option * Remove colors on widgets * Bold label of required fields diff --git a/tryton/gui/window/view_form/view/form_gtk/progressbar.py b/tryton/gui/window/view_form/view/form_gtk/progressbar.py index 755ae9c8c1..4b2ba388a7 100644 --- a/tryton/gui/window/view_form/view/form_gtk/progressbar.py +++ b/tryton/gui/window/view_form/view/form_gtk/progressbar.py @@ -1,9 +1,13 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. import gtk -from .widget import Widget +import gettext import locale +from .widget import Widget + +_ = gettext.gettext + class ProgressBar(Widget): 'Progress Bar' @@ -27,7 +31,9 @@ class ProgressBar(Widget): self.widget.set_text('') self.widget.set_fraction(0.0) return False + value = float(field.get_client(record, factor=100) or 0.0) + digits = field.digits(record, factor=100) + self.widget.set_text(_('%s%%') % + locale.format('%.*f', (digits[1], value), True)) value = float(field.get(record) or 0.0) - digits = field.digits(record) - self.widget.set_text(locale.format('%.*f', (digits[1], value), True)) - self.widget.set_fraction(value / 100.0) + self.widget.set_fraction(value)