2005-07-09 01:54:54 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-04-28 00:49:10 +05:30
|
|
|
# Copyright (C) 2000-2006 Martin Hawlisch, Donald N. Allingham
|
2008-05-19 00:54:28 +05:30
|
|
|
# Copyright (C) 2008 Brian G. Matherly
|
2005-07-09 01:54:54 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
2008-01-29 13:10:35 +05:30
|
|
|
""" Dump Gender Statistics.
|
|
|
|
|
|
|
|
Tools/Debug/Dump Gender Statistics
|
|
|
|
"""
|
2010-01-18 10:12:17 +05:30
|
|
|
from gen.ggettext import gettext as _
|
2005-07-09 01:54:54 +05:30
|
|
|
import gtk
|
|
|
|
import ListModel
|
2006-04-14 10:06:25 +05:30
|
|
|
import ManagedWindow
|
|
|
|
|
2008-10-02 09:32:10 +05:30
|
|
|
from PluginUtils import Tool
|
2005-07-09 01:54:54 +05:30
|
|
|
_GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ]
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-04-14 10:06:25 +05:30
|
|
|
class DumpGenderStats(Tool.Tool, ManagedWindow.ManagedWindow):
|
|
|
|
|
|
|
|
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
2006-04-28 00:49:10 +05:30
|
|
|
self.label = _("Gender Statistics tool")
|
2006-04-14 10:06:25 +05:30
|
|
|
Tool.Tool.__init__(self, dbstate, options_class, name)
|
2006-12-01 21:18:25 +05:30
|
|
|
if uistate:
|
|
|
|
ManagedWindow.ManagedWindow.__init__(self,uistate,[],
|
|
|
|
self.__class__)
|
2005-07-09 01:54:54 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
stats_list = []
|
2009-05-27 02:18:09 +05:30
|
|
|
for name, value in dbstate.db.genderStats.stats.iteritems():
|
2005-12-06 12:08:09 +05:30
|
|
|
stats_list.append(
|
|
|
|
(name,)
|
2009-05-27 02:18:09 +05:30
|
|
|
+ value
|
2006-04-14 10:06:25 +05:30
|
|
|
+ (_GENDER[dbstate.db.genderStats.guess_gender(name)],)
|
2005-12-06 12:08:09 +05:30
|
|
|
)
|
|
|
|
|
2006-04-14 10:06:25 +05:30
|
|
|
if uistate:
|
2005-12-06 12:08:09 +05:30
|
|
|
titles = [
|
2006-06-22 05:39:20 +05:30
|
|
|
(_('Name'),0,100),
|
|
|
|
(_('Male'),1,70,ListModel.INTEGER),
|
|
|
|
(_('Female'),2,70,ListModel.INTEGER),
|
|
|
|
(_('Unknown'),3,70,ListModel.INTEGER),
|
|
|
|
(_('Guess'),4,70)
|
2005-12-06 12:08:09 +05:30
|
|
|
]
|
|
|
|
|
|
|
|
treeview = gtk.TreeView()
|
|
|
|
model = ListModel.ListModel(treeview,titles)
|
|
|
|
for entry in stats_list:
|
|
|
|
model.add(entry,entry[0])
|
2006-04-14 10:06:25 +05:30
|
|
|
|
2006-04-28 00:49:10 +05:30
|
|
|
window = gtk.Window()
|
|
|
|
window.set_default_size(400,300)
|
2005-12-06 12:08:09 +05:30
|
|
|
s = gtk.ScrolledWindow()
|
|
|
|
s.add(treeview)
|
2006-04-28 00:49:10 +05:30
|
|
|
window.add(s)
|
|
|
|
window.show_all()
|
|
|
|
self.set_window(window,None,self.label)
|
|
|
|
self.show()
|
2006-04-14 10:06:25 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
2009-05-27 02:18:09 +05:30
|
|
|
print '\t%s'*5 % ('Name','Male','Female','Unknown','Guess')
|
|
|
|
print
|
2005-12-06 12:08:09 +05:30
|
|
|
for entry in stats_list:
|
2009-05-27 02:18:09 +05:30
|
|
|
print '\t%s'*5 % entry
|
2006-04-28 00:49:10 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def build_menu_names(self, obj):
|
2006-04-28 00:49:10 +05:30
|
|
|
return (self.label,None)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
class DumpGenderStatsOptions(Tool.ToolOptions):
|
|
|
|
"""
|
|
|
|
Defines options and provides handling interface.
|
|
|
|
"""
|
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def __init__(self, name,person_id=None):
|
|
|
|
Tool.ToolOptions.__init__(self, name,person_id)
|