diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2014-07-08 15:52:13 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2014-07-08 15:52:13 (GMT) |
commit | 74b6f1e700a7655c08dece29c77551d511b30e74 (patch) | |
tree | c94e2e96f43710469cded72713398771b7ad1018 | |
parent | 21335bb47e44dc34df74ba3b0e7c60068d048c00 (diff) |
Fix display of elapsed time on the budgetscreen
-rw-r--r-- | budgetscreen.py | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/budgetscreen.py b/budgetscreen.py index 37cd4a3..5f95503 100644 --- a/budgetscreen.py +++ b/budgetscreen.py @@ -31,6 +31,13 @@ locale.setlocale(locale.LC_ALL, '') import colors +# copied from finance.py to not create another module +DAY = 0 +WEEK = 1 +MONTH = 2 +YEAR = 3 +FOREVER = 4 + BUDGET_HELP = _( 'The Budget view allows you to set a monthly budget for each expense ' 'category, and to keep track of your\nbudgets. To set a budget, type ' @@ -149,10 +156,15 @@ class BudgetScreen(Gtk.VBox): def bar_draw_cb(self, widget, cr, category): bounds = widget.get_allocation() + # Draw outline. + cr.set_source_rgb(0.95, 0.95, 0.95) + cr.rectangle(0, 0, bounds.width, bounds.height) + cr.set_line_width(5) + cr.stroke() + # Draw amount of time spent in period if sensible. period_ratio = None - if self.activity.period != _('Day') and \ - self.activity.period != _('Forever'): + if self.activity.period not in (DAY, FOREVER): period_length = ( self.activity.get_next_period( self.activity.period_start) - @@ -166,11 +178,6 @@ class BudgetScreen(Gtk.VBox): cr.rectangle(0, 0, bounds.width * period_ratio, bounds.height) cr.fill() - # Draw outline. - cr.set_source_rgb(0.95, 0.95, 0.95) - cr.rectangle(0, 0, bounds.width, bounds.height) - cr.fill() - # Draw arrow and cost. total = self.category_total[category] @@ -178,13 +185,13 @@ class BudgetScreen(Gtk.VBox): budget = self.activity.data['budgets'][category]['amount'] # Convert from monthly budget. - if self.activity.period == _('Day'): + if self.activity.period == DAY: budget = budget / 30.0 - elif self.activity.period == _('Week'): + elif self.activity.period == WEEK: budget = budget / 4.0 - elif self.activity.period == _('Year'): + elif self.activity.period == YEAR: budget = budget * 12.0 ratio = total / budget |