Merge pull request #333 from sam-m888/9911addcustomcolorstohourglassgraph

9911: Provide an option for custom colors in Hourglass graph
This commit is contained in:
Sam Manzi 2017-01-26 15:39:23 +11:00 committed by GitHub
commit f10ce1c368

View File

@ -41,7 +41,7 @@ from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
from gramps.gen.errors import ReportError from gramps.gen.errors import ReportError
from gramps.gen.plug.menu import (PersonOption, BooleanOption, NumberOption, from gramps.gen.plug.menu import (PersonOption, BooleanOption, NumberOption,
EnumeratedListOption) EnumeratedListOption, ColorOption)
from gramps.gen.plug.report import Report from gramps.gen.plug.report import Report
from gramps.gen.plug.report import utils from gramps.gen.plug.report import utils
from gramps.gen.plug.report import MenuReportOptions from gramps.gen.plug.report import MenuReportOptions
@ -99,28 +99,12 @@ class HourGlassReport(Report):
if self.center_person is None: if self.center_person is None:
raise ReportError(_("Person %s is not in the Database") % pid) raise ReportError(_("Person %s is not in the Database") % pid)
# Would be nice to get rid of these 2 hard-coded arrays of colours
# and instead allow the user to pick-and-choose whatever colour they
# want. When/if this is done, take a look at the colour-selection
# widget and code used in the FamilyLines graph. FIXME
colored = {
'male': 'dodgerblue4',
'female': 'deeppink',
'unknown': 'black',
'family': 'darkgreen'
}
filled = {
'male': 'lightblue',
'female': 'lightpink',
'unknown': 'lightgray',
'family': 'lightyellow'
}
self.colorize = menu.get_option_by_name('color').get_value() self.colorize = menu.get_option_by_name('color').get_value()
if self.colorize == 'colored': self.colors = {'male': menu.get_option_by_name('colormales').get_value(),
self.colors = colored 'female': menu.get_option_by_name('colorfemales').get_value(),
elif self.colorize == 'filled': 'unknown': menu.get_option_by_name('colorunknown').get_value(),
self.colors = filled 'family': menu.get_option_by_name('colorfamilies').get_value()
}
self.roundcorners = menu.get_option_by_name('roundcorners').get_value() self.roundcorners = menu.get_option_by_name('roundcorners').get_value()
self.includeid = menu.get_option_by_name('incid').get_value() self.includeid = menu.get_option_by_name('incid').get_value()
@ -346,6 +330,23 @@ class HourGlassOptions(MenuReportOptions):
"is unknown it will be shown with gray.")) "is unknown it will be shown with gray."))
menu.add_option(category_name, "color", color) menu.add_option(category_name, "color", color)
color_males = ColorOption(_('Males'), '#e0e0ff')
color_males.set_help(_('The color to use to display men.'))
menu.add_option(category_name, 'colormales', color_males)
color_females = ColorOption(_('Females'), '#ffe0e0')
color_females.set_help(_('The color to use to display women.'))
menu.add_option(category_name, 'colorfemales', color_females)
color_unknown = ColorOption(_('Unknown'), '#e0e0e0')
color_unknown.set_help(_('The color to use '
'when the gender is unknown.'))
menu.add_option(category_name, 'colorunknown', color_unknown)
color_family = ColorOption(_('Families'), '#ffffe0')
color_family.set_help(_('The color to use to display families.'))
menu.add_option(category_name, 'colorfamilies', color_family)
roundedcorners = BooleanOption(_("Use rounded corners"), False) # 2180 roundedcorners = BooleanOption(_("Use rounded corners"), False) # 2180
roundedcorners.set_help( roundedcorners.set_help(
_("Use rounded corners to differentiate between women and men.")) _("Use rounded corners to differentiate between women and men."))