* src/plugins/StatisticsChart.py: Misc fixes.
svn: r3893
This commit is contained in:
parent
a7e4980555
commit
7987f99536
@ -1,3 +1,6 @@
|
|||||||
|
2005-01-10 Alex Roitman <shura@alex.neuro.umn.edu>
|
||||||
|
* src/plugins/StatisticsChart.py: Misc fixes.
|
||||||
|
|
||||||
2005-01-10 Eero Tamminen <eerot@sf>
|
2005-01-10 Eero Tamminen <eerot@sf>
|
||||||
* src/plugins/Makefile.am:
|
* src/plugins/Makefile.am:
|
||||||
* src/plugins/StatisticsChart.py:
|
* src/plugins/StatisticsChart.py:
|
||||||
|
@ -47,14 +47,14 @@ import gtk
|
|||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
from Utils import pt2cm
|
from Utils import pt2cm
|
||||||
import const # gender and report type names
|
import const # gender and report type names
|
||||||
from RelLib import Person # need Person internals for getting gender / gender name
|
from RelLib import Person # need Person internals for getting gender / gender name
|
||||||
import Utils
|
import Utils
|
||||||
import Report
|
import Report
|
||||||
import BaseDoc
|
import BaseDoc
|
||||||
import GenericFilter
|
import GenericFilter
|
||||||
import ReportOptions
|
import ReportOptions
|
||||||
import Date
|
from DateHandler import displayer as _dd
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -72,18 +72,13 @@ _lookup_items = {}
|
|||||||
# needs to be global for python sort
|
# needs to be global for python sort
|
||||||
def lookup_value_compare(a, b):
|
def lookup_value_compare(a, b):
|
||||||
"compare given keys according to corresponding _lookup_items values"
|
"compare given keys according to corresponding _lookup_items values"
|
||||||
if _lookup_items[a] < _lookup_items[b]:
|
return cmp(_lookup_items[a],_lookup_items[b])
|
||||||
return -1
|
|
||||||
if _lookup_items[a] == _lookup_items[b]:
|
|
||||||
return 0
|
|
||||||
return 1
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Data extraction methods from the database
|
# Data extraction methods from the database
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
class Extract:
|
class Extract:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -171,7 +166,8 @@ class Extract:
|
|||||||
birth = db.get_event_from_handle(birth_handle).get_date_object()
|
birth = db.get_event_from_handle(birth_handle).get_date_object()
|
||||||
month = birth.get_month()
|
month = birth.get_month()
|
||||||
if month:
|
if month:
|
||||||
return ["Month text here"]#month.getMonthStr()]
|
_dd._months[month]
|
||||||
|
return [_dd._months[month]]
|
||||||
return [_("Person's missing birth month")]
|
return [_("Person's missing birth month")]
|
||||||
|
|
||||||
def death_month(self, db, person):
|
def death_month(self, db, person):
|
||||||
@ -180,7 +176,7 @@ class Extract:
|
|||||||
death = db.get_event_from_handle(death_handle).get_date_object()
|
death = db.get_event_from_handle(death_handle).get_date_object()
|
||||||
month = death.get_month()
|
month = death.get_month()
|
||||||
if month:
|
if month:
|
||||||
return ["Month text here"]#[month.getMonthStr()]
|
return [_dd._months[month]]
|
||||||
return [_("Person's missing death month")]
|
return [_("Person's missing death month")]
|
||||||
|
|
||||||
def death_age(self, db, person):
|
def death_age(self, db, person):
|
||||||
@ -323,7 +319,6 @@ class StatisticsChart(Report.Report):
|
|||||||
self.title = "%s: %04d-%04d" % (extract[0], year_from, year_to)
|
self.title = "%s: %04d-%04d" % (extract[0], year_from, year_to)
|
||||||
|
|
||||||
self.setup()
|
self.setup()
|
||||||
|
|
||||||
|
|
||||||
def index_items(self, sort, reverse):
|
def index_items(self, sort, reverse):
|
||||||
"""creates & stores a sorted index for the items"""
|
"""creates & stores a sorted index for the items"""
|
||||||
@ -436,7 +431,6 @@ class StatisticsChart(Report.Report):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Statistics report options
|
# Statistics report options
|
||||||
@ -466,7 +460,7 @@ class StatisticsChartOptions(ReportOptions.ReportOptions):
|
|||||||
'year_from' : 1700,
|
'year_from' : 1700,
|
||||||
'no_years' : 0,
|
'no_years' : 0,
|
||||||
'extract' : 0,
|
'extract' : 0,
|
||||||
'gender' : 0,
|
'gender' : Person.unknown,
|
||||||
'sort' : _SORT_VALUE,
|
'sort' : _SORT_VALUE,
|
||||||
'reverse' : 0
|
'reverse' : 0
|
||||||
}
|
}
|
||||||
@ -475,11 +469,14 @@ class StatisticsChartOptions(ReportOptions.ReportOptions):
|
|||||||
_("smaller than %d") % self.options_dict['year_to']),
|
_("smaller than %d") % self.options_dict['year_to']),
|
||||||
'year_from' : ("=num", _("Birth year from which to include people"),
|
'year_from' : ("=num", _("Birth year from which to include people"),
|
||||||
_("earlier than 'year_to' value")),
|
_("earlier than 'year_to' value")),
|
||||||
'no_years' : ("=num", _("Include people without birth years"), [_("No"), _("Yes")]),
|
'no_years' : ("=num", _("Include people without birth years"),
|
||||||
'gender' : ("=num", _('Genders included'), self._genders),
|
[_("No"), _("Yes")], False),
|
||||||
'extract' : ("=num", _('Data to show'), [item[0] for item in _Extract.extractors]),
|
'gender' : ("=num", _('Genders included'), str(self._genders), False),
|
||||||
'sort' : ("=num", _('Sorted by'), self._sorts),
|
'extract' : ("=num", _('Data to show'),
|
||||||
'reverse' : ("=num", _("Sort in reverse order"), [_("Yes"), _("No")])
|
str([item[0] for item in _Extract.extractors]),False),
|
||||||
|
'sort' : ("=num", _('Sorted by'), str(self._sorts), False),
|
||||||
|
'reverse' : ("=num", _("Sort in reverse order"),
|
||||||
|
[_("Yes"), _("No")], False)
|
||||||
}
|
}
|
||||||
|
|
||||||
def enable_options(self):
|
def enable_options(self):
|
||||||
@ -542,37 +539,27 @@ class StatisticsChartOptions(ReportOptions.ReportOptions):
|
|||||||
report specific options
|
report specific options
|
||||||
"""
|
"""
|
||||||
# what data to extract from database
|
# what data to extract from database
|
||||||
self.extract_menu = gtk.Menu()
|
self.extract_menu = gtk.combo_box_new_text()
|
||||||
idx = 0
|
|
||||||
for item in _Extract.extractors:
|
for item in _Extract.extractors:
|
||||||
menuitem = gtk.MenuItem(item[0])
|
self.extract_menu.append_text(item[0])
|
||||||
menuitem.set_data('extract', idx)
|
self.extract_menu.set_active(self.options_dict['extract'])
|
||||||
self.extract_menu.append(menuitem)
|
|
||||||
idx += 1
|
|
||||||
self.extract_menu.show_all()
|
|
||||||
|
|
||||||
tip = _("Select which data is collected and which statistics is shown.")
|
tip = _("Select which data is collected and which statistics is shown.")
|
||||||
extract_style = gtk.OptionMenu()
|
dialog.add_option(self.options_help['extract'][1], self.extract_menu, tip)
|
||||||
extract_style.set_menu(self.extract_menu)
|
|
||||||
dialog.add_option(self.options_help['extract'][1], extract_style, tip)
|
|
||||||
|
|
||||||
# how to sort the data
|
# how to sort the data
|
||||||
self.sort_menu = gtk.Menu()
|
self.sort_menu = gtk.combo_box_new_text()
|
||||||
for item in self._sorts:
|
for item_idx in range(len(self._sorts)):
|
||||||
menuitem = gtk.MenuItem(item[1])
|
item = self._sorts[item_idx]
|
||||||
menuitem.set_data('sort', item[0])
|
self.sort_menu.append_text(item[1])
|
||||||
self.sort_menu.append(menuitem)
|
if item[0] == self.options_dict['sort']:
|
||||||
self.sort_menu.show_all()
|
self.sort_menu.set_active(item_idx)
|
||||||
|
|
||||||
tip = _("Select how the statistical data is sorted.")
|
tip = _("Select how the statistical data is sorted.")
|
||||||
sort_style = gtk.OptionMenu()
|
dialog.add_option(self.options_help['sort'][1], self.sort_menu, tip)
|
||||||
sort_style.set_menu(self.sort_menu)
|
|
||||||
dialog.add_option(self.options_help['sort'][1], sort_style, tip)
|
|
||||||
|
|
||||||
# sorting order
|
# sorting order
|
||||||
tip = _("Check to reverse the sorting order.")
|
tip = _("Check to reverse the sorting order.")
|
||||||
self.reverse = gtk.CheckButton(self.options_help['reverse'][1])
|
self.reverse = gtk.CheckButton(self.options_help['reverse'][1])
|
||||||
self.reverse.set_active(0)
|
self.reverse.set_active(self.options_dict['reverse'])
|
||||||
dialog.add_option(None, self.reverse, tip)
|
dialog.add_option(None, self.reverse, tip)
|
||||||
self.reverse.show()
|
self.reverse.show()
|
||||||
|
|
||||||
@ -593,22 +580,19 @@ class StatisticsChartOptions(ReportOptions.ReportOptions):
|
|||||||
# include people without birth year?
|
# include people without birth year?
|
||||||
tip = _("Check this if you want people who have no birth date or year to be accounted also in the statistics.")
|
tip = _("Check this if you want people who have no birth date or year to be accounted also in the statistics.")
|
||||||
self.no_years = gtk.CheckButton(self.options_help['no_years'][1])
|
self.no_years = gtk.CheckButton(self.options_help['no_years'][1])
|
||||||
self.no_years.set_active(0)
|
self.no_years.set_active(self.options_dict['no_years'])
|
||||||
dialog.add_option(None, self.no_years, tip)
|
dialog.add_option(None, self.no_years, tip)
|
||||||
self.no_years.show()
|
self.no_years.show()
|
||||||
|
|
||||||
# gender selection
|
# gender selection
|
||||||
self.gender_menu = gtk.Menu()
|
self.gender_menu = gtk.combo_box_new_text()
|
||||||
for item in self._genders:
|
for item_idx in range(len(self._genders)):
|
||||||
menuitem = gtk.MenuItem(item[1])
|
item = self._genders[item_idx]
|
||||||
menuitem.set_data('gender', item[0])
|
self.gender_menu.append_text(item[1])
|
||||||
self.gender_menu.append(menuitem)
|
if item[0] == self.options_dict['gender']:
|
||||||
self.gender_menu.show_all()
|
self.gender_menu.set_active(item_idx)
|
||||||
|
|
||||||
tip = _("Select which genders are included into statistics.")
|
tip = _("Select which genders are included into statistics.")
|
||||||
genders = gtk.OptionMenu()
|
dialog.add_option(self.options_help['gender'][1], self.gender_menu, tip)
|
||||||
genders.set_menu(self.gender_menu)
|
|
||||||
dialog.add_option(self.options_help['gender'][1], genders, tip)
|
|
||||||
|
|
||||||
def parse_user_options(self, dialog):
|
def parse_user_options(self, dialog):
|
||||||
"""
|
"""
|
||||||
@ -617,12 +601,11 @@ class StatisticsChartOptions(ReportOptions.ReportOptions):
|
|||||||
self.options_dict['year_to'] = int(self.to_box.get_text())
|
self.options_dict['year_to'] = int(self.to_box.get_text())
|
||||||
self.options_dict['year_from'] = int(self.from_box.get_text())
|
self.options_dict['year_from'] = int(self.from_box.get_text())
|
||||||
self.options_dict['no_years'] = int(self.no_years.get_active())
|
self.options_dict['no_years'] = int(self.no_years.get_active())
|
||||||
self.options_dict['gender'] = self.gender_menu.get_active().get_data('gender')
|
self.options_dict['gender'] = self.gender_menu.get_active()
|
||||||
self.options_dict['extract'] = self.extract_menu.get_active().get_data('extract')
|
self.options_dict['extract'] = self.extract_menu.get_active()
|
||||||
self.options_dict['sort'] = self.sort_menu.get_active().get_data('sort')
|
self.options_dict['sort'] = self.sort_menu.get_active()
|
||||||
self.options_dict['reverse'] = int(self.reverse.get_active())
|
self.options_dict['reverse'] = int(self.reverse.get_active())
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Register report/options
|
# Register report/options
|
||||||
|
Loading…
x
Reference in New Issue
Block a user