Updates to gramplets with options

svn: r14346
This commit is contained in:
Doug Blank 2010-02-13 03:21:38 +00:00
parent 6717242366
commit cf03374f70
3 changed files with 35 additions and 22 deletions

View File

@ -34,8 +34,8 @@ import gen.lib
class AgeStatsGramplet(Gramplet):
def init(self):
self.max_age = 120
self.max_mother_diff = 60
self.max_age = 110
self.max_mother_diff = 40
self.max_father_diff = 60
self.chart_width = 60
@ -63,18 +63,17 @@ class AgeStatsGramplet(Gramplet):
self.no_wrap()
tag = self.gui.buffer.create_tag("fixed")
tag.set_property("font", "Courier 8")
# FIXME: something wrong saving ordered data list?!
# if len(self.gui.data) > 0:
# self.max_age = int(self.gui.data[0])
# if len(self.gui.data) > 1:
# self.max_mother_diff = int(self.gui.data[1])
# if len(self.gui.data) > 2:
# self.max_father_diff = int(self.gui.data[2])
# if len(self.gui.data) > 3:
# self.chart_width = int(self.gui.data[3])
if len(self.gui.data) == 4:
self.max_age = int(self.gui.data[0])
self.max_mother_diff = int(self.gui.data[1])
self.max_father_diff = int(self.gui.data[2])
self.chart_width = int(self.gui.data[3])
# def on_save(self):
# self.gui.data = [self.max_age, self.max_mother_diff, self.max_father_diff, self.chart_width]
def on_save(self):
self.gui.data = [self.max_age,
self.max_mother_diff,
self.max_father_diff,
self.chart_width]
def db_changed(self):
self.update()

View File

@ -55,20 +55,25 @@ class PedigreeGramplet(Gramplet):
self.box_mode = "UTF"
def build_options(self):
from gen.plug.menu import NumberOption
from gen.plug.menu import NumberOption, BooleanOption, EnumeratedListOption
self.add_option(NumberOption(_("Max generations"),
self.max_generations, 1, 100))
self.add_option(BooleanOption(_("Show dates"), bool(self.show_dates)))
elist = EnumeratedListOption(_("Line type"), self.box_mode)
elist.add_item("UTF", "UTF")
elist.add_item("ASCII", "ASCII")
self.add_option(elist)
def save_options(self):
self.max_generations = int(self.get_option(_("Max generations")).get_value())
self.show_dates = int(self.get_option(_("Show dates")).get_value())
self.box_mode = self.get_option(_("Line type")).get_value()
def on_load(self):
if len(self.gui.data) > 0:
if len(self.gui.data) == 3:
self.max_generations = int(self.gui.data[0])
if len(self.gui.data) > 1:
self.show_dates = int(self.gui.data[1])
if len(self.gui.data) > 2:
self.box_mode = self.gui.data[2] # ASCII or UTF
self.box_mode = self.gui.data[2] # "ASCII" or "UTF"
def on_save(self):
self.gui.data = [self.max_generations, self.show_dates, self.box_mode]

View File

@ -61,6 +61,8 @@ class SurnameCloudGramplet(Gramplet):
def init(self):
self.set_tooltip(_("Double-click surname for details"))
self.top_size = 150 # will be overwritten in load
self.min_font = 8
self.max_font = 20
self.set_text(_("No Family Tree loaded."))
def db_changed(self):
@ -71,11 +73,13 @@ class SurnameCloudGramplet(Gramplet):
self.dbstate.db.connect('family-rebuild', self.update)
def on_load(self):
if len(self.gui.data) > 0:
if len(self.gui.data) == 3:
self.top_size = int(self.gui.data[0])
self.min_font = int(self.gui.data[1])
self.max_font = int(self.gui.data[2])
def on_save(self):
self.gui.data = [self.top_size]
self.gui.data = [self.top_size, self.min_font, self.max_font]
def main(self):
self.set_text(_("Processing...") + "\n")
@ -157,8 +161,13 @@ class SurnameCloudGramplet(Gramplet):
from gen.plug.menu import NumberOption
self.top_size_option = NumberOption(_("Number of surnames"), self.top_size, 1, 150)
self.add_option(self.top_size_option)
self.min_option = NumberOption(_("Min font size"), 8, 1, 50)
self.min_option = NumberOption(_("Min font size"), self.min_font, 1, 50)
self.add_option(self.min_option)
self.max_option = NumberOption(_("Max font size"), 20, 1, 50)
self.max_option = NumberOption(_("Max font size"), self.max_font, 1, 50)
self.add_option(self.max_option)
def save_options(self):
self.top_size = int(self.get_option(_("Number of surnames")).get_value())
self.min_font = int(self.get_option(_("Min font size")).get_value())
self.max_font = int(self.get_option(_("Max font size")).get_value())