More pylint improvements

This commit is contained in:
Nick Hall 2016-06-01 23:52:59 +01:00
parent 5f1b719810
commit 32ff947a87
37 changed files with 460 additions and 318 deletions

View File

@ -21,22 +21,16 @@ AgeOnDateGramplet computes the age for everyone thought to be alive
on a particular date.
"""
#------------------------------------------------------------------------
#
# Python modules
#
#------------------------------------------------------------------------
#------------------------------------------------------------------------
#
# Gramps modules
#
#------------------------------------------------------------------------
from gramps.gen.plug import Gramplet
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from gramps.gen.datehandler import parser
from gramps.gui.plug.quick import run_quick_report_by_name
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
#------------------------------------------------------------------------
#

View File

@ -28,7 +28,6 @@ This Gramplet shows textual distributions of age breakdowns of various types.
# Python modules
#
#-------------------------------------------------------------------------
from collections import defaultdict
#------------------------------------------------------------------------
@ -36,11 +35,10 @@ from collections import defaultdict
# Gramps modules
#
#------------------------------------------------------------------------
from gramps.gen.plug import Gramplet
from gramps.gen.lib import ChildRefType
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.lib import ChildRefType
class AgeStatsGramplet(Gramplet):
@ -269,13 +267,16 @@ class AgeStatsGramplet(Gramplet):
max_bin = float(max(bin))
if max_bin != 0:
i = 0
self.append_text("--------" +
self.append_text(
"--------" +
self.format("", graph_width-4, fill="-", borders="++") +
"-----\n")
self.append_text(column.center(8) +
self.append_text(
column.center(8) +
self.format(title, graph_width-4, align="center") +
" % " + "\n")
self.append_text("--------" +
self.append_text(
"--------" +
self.format("", graph_width-4, fill="-", borders="++") +
"-----\n")
for bin in bin:
@ -292,10 +293,12 @@ class AgeStatsGramplet(Gramplet):
self.append_text(glocale.format("%#5.2f", procent))
self.append_text("\n")
i += 1
self.append_text("--------" +
self.append_text(
"--------" +
self.format("", graph_width-4, fill="-", borders="++") +
"-----\n")
self.append_text(" % " +
self.append_text(
" % " +
self.ticks(graph_width-4, start=0,
stop=int(max_bin/(float(sum(hash.values())))*100)) +
"\n\n")

View File

@ -45,7 +45,9 @@ from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
class Ancestor(Gramplet):
"""
Gramplet to display ancestors of the active person.
"""
def init(self):
self.gui.WIDGET = self.build_gui()
self.gui.get_container_widget().remove(self.gui.textview)
@ -120,6 +122,9 @@ class Ancestor(Gramplet):
self.set_has_data(False)
def add_to_tree(self, depth, parent_id, person_handle):
"""
Add a person to the tree.
"""
if depth > config.get('behavior.generation-depth'):
return

View File

@ -17,12 +17,23 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from gramps.gui.listmodel import ListModel, NOSORT
#-------------------------------------------------------------------------
#
# Gtk modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gui.listmodel import ListModel
from gramps.gui.plug.quick import run_quick_report_by_name
from gramps.gen.plug import Gramplet
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gi.repository import Gtk
class Attributes(Gramplet):
"""

View File

@ -18,13 +18,24 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from gramps.gui.listmodel import ListModel, NOSORT
#-------------------------------------------------------------------------
#
# Gtk modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gui.listmodel import ListModel
from gramps.gen.utils.db import navigation_label
from gramps.gen.plug import Gramplet
from gramps.gui.utils import edit_object
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gi.repository import Gtk
class Backlinks(Gramplet):
"""

View File

@ -16,16 +16,24 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#------------------------------------------------------------------------
#
# Gtk modules
#
#------------------------------------------------------------------------
from gi.repository import Gtk
#------------------------------------------------------------------------
#
# Gramps modules
#
#------------------------------------------------------------------------
from gramps.gen.plug import Gramplet
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from gramps.gui.plug.quick import run_quick_report_by_name
from gramps.gen.lib import Date
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
#------------------------------------------------------------------------
#
@ -33,11 +41,14 @@ from gramps.gen.lib import Date
#
#------------------------------------------------------------------------
class CalendarGramplet(Gramplet):
"""
Gramplet showing a calendar of events.
"""
def init(self):
from gi.repository import Gtk
self.set_tooltip(_("Double-click a day for details"))
self.gui.calendar = Gtk.Calendar()
self.gui.calendar.connect('day-selected-double-click', self.double_click)
self.gui.calendar.connect('day-selected-double-click',
self.double_click)
self.gui.calendar.set_display_options(
Gtk.CalendarDisplayOptions.SHOW_HEADING)
self.gui.get_container_widget().remove(self.gui.textview)
@ -45,13 +56,14 @@ class CalendarGramplet(Gramplet):
vbox.pack_start(self.gui.calendar, False, False, 0)
self.gui.get_container_widget().add(vbox)
vbox.show_all()
#self.gui.calendar.show()
def post_init(self):
self.disconnect("active-changed")
def double_click(self, obj):
# bring up events on this day
"""
Bring up events on this day.
"""
year, month, day = self.gui.calendar.get_date()
date = Date()
date.set_yr_mon_day(year, month + 1, day)

View File

@ -17,18 +17,29 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#-------------------------------------------------------------------------
#
# Gtk modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gui.editors import EditPerson
from gramps.gui.listmodel import ListModel, NOSORT
from gramps.gen.plug import Gramplet
from gramps.gen.plug.report.utils import find_spouse
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback
from gramps.gen.datehandler import get_date
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.errors import WindowActiveError
from gi.repository import Gtk
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
class Children(Gramplet):
"""

View File

@ -18,14 +18,25 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#-------------------------------------------------------------------------
#
# Gtk modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gui.editors import EditSource, EditCitation
from gramps.gui.listmodel import ListModel, NOSORT
from gramps.gen.plug import Gramplet
from gramps.gui.dbguielement import DbGUIElement
from gramps.gen.errors import WindowActiveError
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.errors import WindowActiveError
from gi.repository import Gtk
class Citations(Gramplet, DbGUIElement):

View File

@ -20,21 +20,12 @@
"""Descendant Gramplet"""
#------------------------------------------------------------------------
#
# Python modules
#
#------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#-------------------------------------------------------------------------
#
# GTK modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
from gi.repository import Gdk
#------------------------------------------------------------------------
#
@ -49,9 +40,13 @@ from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.datehandler import get_date
from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback
from gramps.gui.utils import model_to_text, text_to_clipboard
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
class Descendant(Gramplet):
"""
Gramplet to display descendants of the active person.
"""
def init(self):
self.gui.WIDGET = self.build_gui()
self.gui.get_container_widget().remove(self.gui.textview)
@ -112,7 +107,8 @@ class Descendant(Gramplet):
menu = Gtk.Menu()
menu.set_title(_('Descendent Menu'))
entries = [
(_("Edit"), lambda obj: self.cb_double_click(treeview), sensitivity),
(_("Edit"), lambda obj: self.cb_double_click(treeview),
sensitivity),
(None, None, 0),
(_("Copy all"), lambda obj: self.on_copy_all(treeview), 1),
]
@ -127,6 +123,9 @@ class Descendant(Gramplet):
self.menu.popup(None, None, None, None, event.button, event.time)
def on_copy_all(self, treeview):
"""
Copy tree to clipboard.
"""
model = treeview.get_model()
text = model_to_text(model, [0, 1], level=1)
text_to_clipboard(text)
@ -155,6 +154,9 @@ class Descendant(Gramplet):
self.set_has_data(False)
def add_to_tree(self, parent_id, person_handle):
"""
Add a person to the tree.
"""
person = self.dbstate.db.get_person_from_handle(person_handle)
name = name_displayer.display(person)

View File

@ -30,8 +30,6 @@ Provide a python evaluation window
#------------------------------------------------------------------------
import sys
from io import StringIO
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
import traceback
#-------------------------------------------------------------------------
@ -47,6 +45,8 @@ from gi.repository import Gtk
#
#------------------------------------------------------------------------
from gramps.gen.plug import Gramplet
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#-------------------------------------------------------------------------
#

View File

@ -17,23 +17,32 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#-------------------------------------------------------------------------
#
# Gtk modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gui.editors import EditEvent
from gramps.gen.lib import EventRoleType
from gramps.gui.listmodel import ListModel, NOSORT
from gramps.gen.plug import Gramplet
from gramps.gen.plug.report.utils import find_spouse
from gramps.gui.dbguielement import DbGUIElement
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.datehandler import get_date
from gramps.gen.utils.db import (get_participant_from_event,
get_birth_or_fallback,
get_marriage_or_fallback)
from gramps.gen.errors import WindowActiveError
from gi.repository import Gtk
from gramps.gen.config import config
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
age_precision = config.get('preferences.age-display-precision')

View File

@ -19,35 +19,18 @@
## Based on the normal fanchart
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Pango
from gi.repository import Gtk
import math
from gi.repository import Gdk
try:
import cairo
except ImportError:
pass
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.plug import Gramplet
from gramps.gen.errors import WindowActiveError
from gramps.gui.editors import EditPerson
from gramps.gui.widgets.fanchartdesc import (FanChartDescWidget, FanChartDescGrampsGUI,
from gramps.gui.widgets.fanchartdesc import (FanChartDescWidget,
FanChartDescGrampsGUI,
ANGLE_WEIGHT)
from gramps.gui.widgets.fanchart import FORM_HALFCIRCLE, BACKGROUND_SCHEME1
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
class FanChartDescGramplet(FanChartDescGrampsGUI, Gramplet):
"""
@ -67,7 +50,8 @@ class FanChartDescGramplet(FanChartDescGrampsGUI, Gramplet):
self.alpha_filter = 0.2
self.form = FORM_HALFCIRCLE
self.angle_algo = ANGLE_WEIGHT
self.set_fan(FanChartDescWidget(self.dbstate, self.uistate, self.on_popup))
self.set_fan(FanChartDescWidget(self.dbstate, self.uistate,
self.on_popup))
# Replace the standard textview with the fan chart widget:
self.gui.get_container_widget().remove(self.gui.textview)
self.gui.get_container_widget().add(self.fan)
@ -75,7 +59,9 @@ class FanChartDescGramplet(FanChartDescGrampsGUI, Gramplet):
self.fan.show()
def init(self):
self.set_tooltip(_("Click to expand/contract person\nRight-click for options\nClick and drag in open area to rotate"))
self.set_tooltip(_("Click to expand/contract person\n"
"Right-click for options\n"
"Click and drag in open area to rotate"))
def active_changed(self, handle):
"""

View File

@ -25,34 +25,16 @@
## Found by redwood:
## http://www.gramps-project.org/bugs/view.php?id=2611
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Pango
from gi.repository import Gtk
import math
from gi.repository import Gdk
try:
import cairo
except ImportError:
pass
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.plug import Gramplet
from gramps.gen.errors import WindowActiveError
from gramps.gui.editors import EditPerson
from gramps.gui.widgets.fanchart import (FanChartWidget, FanChartGrampsGUI,
FORM_HALFCIRCLE, BACKGROUND_SCHEME1)
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
class FanChartGramplet(FanChartGrampsGUI, Gramplet):
"""
@ -80,7 +62,8 @@ class FanChartGramplet(FanChartGrampsGUI, Gramplet):
self.fan.show()
def init(self):
self.set_tooltip(_("Click to expand/contract person\nRight-click for options\nClick and drag in open area to rotate"))
self.set_tooltip(_("Click to expand/contract person\nRight-click for "
"options\nClick and drag in open area to rotate"))
def active_changed(self, handle):
"""

View File

@ -28,9 +28,9 @@
#
#------------------------------------------------------------------------
from gramps.gen.plug import Gramplet
from gramps.gen.const import URL_MANUAL_PAGE
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from gramps.gen.const import URL_MANUAL_PAGE
#------------------------------------------------------------------------
#

View File

@ -19,17 +19,20 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
"""
Module providing a gramplet interface to the sidebar filters.
"""
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.plug import Gramplet
from gramps.gui.filters.sidebar import (PersonSidebarFilter, FamilySidebarFilter,
EventSidebarFilter, SourceSidebarFilter,
CitationSidebarFilter,
PlaceSidebarFilter, MediaSidebarFilter,
RepoSidebarFilter, NoteSidebarFilter)
from gramps.gui.filters.sidebar import (
PersonSidebarFilter, FamilySidebarFilter, EventSidebarFilter,
SourceSidebarFilter, CitationSidebarFilter, PlaceSidebarFilter,
MediaSidebarFilter, RepoSidebarFilter, NoteSidebarFilter)
#-------------------------------------------------------------------------
#

View File

@ -18,11 +18,22 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#------------------------------------------------------------------------
#
# Gtk
#
#------------------------------------------------------------------------
from gi.repository import Gtk
#------------------------------------------------------------------------
#
# Gramps modules
#
#------------------------------------------------------------------------
from gramps.gen.plug import Gramplet
from gramps.gui.widgets import Photo
from gramps.gen.utils.thumbnails import get_thumbnail_image
from gramps.gen.utils.file import media_path_full
from gi.repository import Gtk
class Gallery(Gramplet):
"""
@ -67,8 +78,7 @@ class Gallery(Gramplet):
else:
photo = Photo(self.uistate.screen_height() < 1000)
photo.set_pixbuf(full_path,
get_thumbnail_image(full_path,
mime_type,
get_thumbnail_image(full_path, mime_type,
media_ref.get_rectangle()))
self.image_list.append(photo)
self.top.pack_start(photo, False, False, 0)

View File

@ -18,12 +18,23 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#
from collections import defaultdict
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
from collections import defaultdict
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.plug import Gramplet
from gramps.gen.config import config
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
_YIELD_INTERVAL = 350
@ -66,12 +77,12 @@ class GivenNameCloudGramplet(Gramplet):
allnames = [person.get_primary_name()] + person.get_alternate_names()
allnames = set(name.get_first_name().strip() for name in allnames)
for givenname in allnames:
anyNBSP = givenname.split('\u00A0')
if len(anyNBSP) > 1: # there was an NBSP, a non-breaking space
first_two = anyNBSP[0] + '\u00A0' + anyNBSP[1].split()[0]
nbsp = givenname.split('\u00A0')
if len(nbsp) > 1: # there was an NBSP, a non-breaking space
first_two = nbsp[0] + '\u00A0' + nbsp[1].split()[0]
givensubnames[first_two] += 1
representative_handle[first_two] = person.handle
givenname = ' '.join(anyNBSP[1].split()[1:])
givenname = ' '.join(nbsp[1].split()[1:])
for givensubname in givenname.split():
givensubnames[givensubname] += 1
representative_handle[givensubname] = person.handle
@ -84,7 +95,8 @@ class GivenNameCloudGramplet(Gramplet):
total = cnt = 0
for givensubname in givensubnames:
givensubname_sort.append( (givensubnames[givensubname], givensubname) )
givensubname_sort.append((givensubnames[givensubname],
givensubname))
total += givensubnames[givensubname]
cnt += 1
if not cnt % _YIELD_INTERVAL:

View File

@ -24,14 +24,6 @@
Show uncollected objects in a window.
"""
#------------------------------------------------------------------------
#
# standard python modules
#
#------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#------------------------------------------------------------------------
#
# GNOME/GTK modules
@ -49,6 +41,8 @@ import gc
from gramps.gen.plug import Gramplet
from gramps.gui.dialog import InfoDialog
from gramps.gui.utils import is_right_click
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#-------------------------------------------------------------------------
#

View File

@ -19,7 +19,7 @@
#-------------------------------------------------------------------------
#
# Python modules
# Gtk modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
@ -162,7 +162,9 @@ class Locations(Gramplet, DbGUIElement):
#
#-------------------------------------------------------------------------
class EnclosedBy(Locations):
"""
Gramplet showing the locations enclosed by the active place.
"""
def display_place(self, place, node, visited):
"""
Display the location hierarchy for the active place.
@ -194,7 +196,9 @@ class EnclosedBy(Locations):
#
#-------------------------------------------------------------------------
class Encloses(Locations):
"""
Gramplet showing the locations which the active place encloses.
"""
def display_place(self, place, node, visited):
"""
Display the location hierarchy for the active place.

View File

@ -17,10 +17,21 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#-------------------------------------------------------------------------
#
# Gtk modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.plug import Gramplet
from gramps.gui.widgets import Photo
from gramps.gen.utils.file import media_path_full
from gi.repository import Gtk
class MediaPreview(Gramplet):
"""
@ -72,7 +83,6 @@ class MediaPreview(Gramplet):
"""
Load the primary image if it exists.
"""
self.full_path = media_path_full(self.dbstate.db,
media.get_path())
self.full_path = media_path_full(self.dbstate.db, media.get_path())
mime_type = media.get_mime_type()
self.photo.set_image(self.full_path, mime_type)

View File

@ -18,13 +18,24 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#------------------------------------------------------------------------
#
# Gtk
#
#------------------------------------------------------------------------
from gi.repository import Gtk
#------------------------------------------------------------------------
#
# Gramps modules
#
#------------------------------------------------------------------------
from gramps.gen.plug import Gramplet
from gramps.gui.widgets.styledtexteditor import StyledTextEditor
from gramps.gui.widgets import SimpleButton
from gramps.gen.lib import StyledText
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gi.repository import Gtk
class Notes(Gramplet):
"""
@ -53,7 +64,8 @@ class Notes(Gramplet):
hbox.pack_end(self.page, False, False, 10)
scrolledwindow = Gtk.ScrolledWindow()
scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC,
Gtk.PolicyType.AUTOMATIC)
self.texteditor = StyledTextEditor()
self.texteditor.set_editable(False)
self.texteditor.set_wrap_mode(Gtk.WrapMode.WORD)
@ -96,7 +108,8 @@ class Notes(Gramplet):
note_handle = self.note_list[self.current]
note = self.dbstate.db.get_note_from_handle(note_handle)
self.texteditor.set_text(note.get_styledtext())
self.page.set_text(_('%(current)d of %(total)d') % {'current': self.current + 1,
self.page.set_text(_('%(current)d of %(total)d') %
{'current': self.current + 1,
'total': len(self.note_list)})
def left_clicked(self, button):

View File

@ -29,14 +29,16 @@ from html import escape
# Gramps modules
#
#------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
ngettext = glocale.translation.ngettext # else "nearby" comments are ignored
from gramps.gen.plug import Gramplet
from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.datehandler import get_date
from gramps.gen.lib import EventType
from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback
from gramps.gen.plug.menu import (NumberOption, BooleanOption,
EnumeratedListOption)
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
ngettext = glocale.translation.ngettext # else "nearby" comments are ignored
#------------------------------------------------------------------------
#
@ -53,7 +55,6 @@ class PedigreeGramplet(Gramplet):
self.box_mode = "UTF"
def build_options(self):
from gramps.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)))

View File

@ -18,17 +18,28 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#-------------------------------------------------------------------------
#
# Gtk modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
from gi.repository import Pango
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.lib import EventType, EventRoleType
from gramps.gen.plug import Gramplet
from gramps.gui.widgets import Photo
from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.datehandler import get_date
from gramps.gen.utils.file import media_path_full
from gi.repository import Gtk
from gi.repository import Pango
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
class PersonDetails(Gramplet):
"""

View File

@ -17,16 +17,27 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#-------------------------------------------------------------------------
#
# Gtk modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.lib import EventType, EventRoleType
from gramps.gui.editors import EditEvent
from gramps.gui.listmodel import ListModel, NOSORT
from gramps.gen.plug import Gramplet
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.datehandler import get_date
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.errors import WindowActiveError
from gi.repository import Gtk
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
class PersonResidence(Gramplet):
"""

View File

@ -17,15 +17,26 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#-------------------------------------------------------------------------
#
# Gtk modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
from gi.repository import Pango
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.plug import Gramplet
from gramps.gui.widgets import Photo
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.utils.place import conv_lat_lon
from gramps.gen.utils.file import media_path_full
from gramps.gen.display.place import displayer as place_displayer
from gi.repository import Gtk
from gi.repository import Pango
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
class PlaceDetails(Gramplet):
"""

View File

@ -30,14 +30,15 @@
#
#------------------------------------------------------------------------
from gramps.gen.plug import Gramplet
from gramps.gui.plug.quick import (run_quick_report_by_name,
get_quick_report_list)
from gramps.gen.plug import (
CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY, CATEGORY_QR_EVENT,
CATEGORY_QR_SOURCE, CATEGORY_QR_NOTE, CATEGORY_QR_PLACE,
CATEGORY_QR_MEDIA, CATEGORY_QR_REPOSITORY, CATEGORY_QR_CITATION,
CATEGORY_QR_SOURCE_OR_CITATION)
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from gramps.gui.plug.quick import run_quick_report_by_name, get_quick_report_list
from gramps.gen.plug import (CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY,
CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE, CATEGORY_QR_NOTE,
CATEGORY_QR_MISC, CATEGORY_QR_PLACE, CATEGORY_QR_MEDIA,
CATEGORY_QR_REPOSITORY, CATEGORY_QR_CITATION,
CATEGORY_QR_SOURCE_OR_CITATION)
#------------------------------------------------------------------------
#

View File

@ -20,14 +20,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#------------------------------------------------------------------------
#
# Standard Python modules
#
#------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
#------------------------------------------------------------------------
#
# Gramps modules
@ -35,10 +27,12 @@ _ = glocale.translation.sgettext
#------------------------------------------------------------------------
from gramps.plugins.lib.librecords import find_records, CALLNAME_DONTUSE
from gramps.gen.plug import Gramplet
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
#------------------------------------------------------------------------
#
# The Gramplet
# RecordsGramplet
#
#------------------------------------------------------------------------
class RecordsGramplet(Gramplet):

View File

@ -22,9 +22,9 @@
#
#------------------------------------------------------------------------
from gramps.gen.plug import Gramplet
from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from gramps.gen.display.name import displayer as name_displayer
#------------------------------------------------------------------------
#

View File

@ -17,12 +17,23 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#-------------------------------------------------------------------------
#
# Gtk
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
from gi.repository import Pango
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.lib import UrlType
from gramps.gen.plug import Gramplet
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gi.repository import Gtk
from gi.repository import Pango
class RepositoryDetails(Gramplet):
"""

View File

@ -32,10 +32,10 @@ import time
from gramps.gen.lib import Person, Family
from gramps.gen.db import PERSON_KEY, FAMILY_KEY, TXNDEL
from gramps.gen.plug import Gramplet
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.utils.db import family_name
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
#------------------------------------------------------------------------
#

View File

@ -29,11 +29,11 @@ import posixpath
#
#------------------------------------------------------------------------
from gramps.gen.plug import Gramplet
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from gramps.gen.utils.file import media_path_full
from gramps.gen.datehandler import get_date
from gramps.gen.lib import Person
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
#------------------------------------------------------------------------
#
@ -90,9 +90,9 @@ class StatsGramplet(Gramplet):
except OSError:
notfound.append(media.get_path())
males = sum([v[0] for v in database.genderStats.stats.values()]) # male, female, unknown
females = sum([v[1] for v in database.genderStats.stats.values()]) # male, female, unknown
unknown = sum([v[2] for v in database.genderStats.stats.values()]) # male, female, unknown
males = sum([v[0] for v in database.genderStats.stats.values()])
females = sum([v[1] for v in database.genderStats.stats.values()])
unknown = sum([v[2] for v in database.genderStats.stats.values()])
self.clear_text()
self.append_text(_("Individuals") + "\n")

View File

@ -16,6 +16,11 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#------------------------------------------------------------------------
#
# Python modules
#
#------------------------------------------------------------------------
from collections import defaultdict
#------------------------------------------------------------------------
@ -24,9 +29,9 @@ from collections import defaultdict
#
#------------------------------------------------------------------------
from gramps.gen.plug import Gramplet
from gramps.gen.config import config
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from gramps.gen.config import config
#------------------------------------------------------------------------
#

View File

@ -17,6 +17,18 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#-------------------------------------------------------------------------
#
# Gtk modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.plug import Gramplet
from gramps.gui.widgets.styledtexteditor import StyledTextEditor
from gramps.gui.widgets import SimpleButton
@ -24,7 +36,6 @@ from gramps.gen.lib import StyledText, Note, NoteType
from gramps.gen.db import DbTxn
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gi.repository import Gtk
class ToDo(Gramplet):
"""

View File

@ -18,14 +18,24 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#-------------------------------------------------------------------------
#
# Gtk modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.plug import Gramplet
from gramps.gui.widgets.styledtexteditor import StyledTextEditor
from gramps.gui.widgets import SimpleButton
from gramps.gen.lib import StyledText, Note, NoteType
from gramps.gen.filters import GenericFilterFactory, rules
from gramps.gen.utils.db import navigation_label
from gramps.gen.db import DbTxn
from gi.repository import Gtk
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext

View File

@ -21,7 +21,6 @@
# Python modules
#
#------------------------------------------------------------------------
from collections import defaultdict
#------------------------------------------------------------------------
@ -30,16 +29,15 @@ from collections import defaultdict
#
#------------------------------------------------------------------------
from gramps.gen.plug import Gramplet
from gramps.gen.config import config
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from gramps.gen.config import config
#------------------------------------------------------------------------
#
# Constants
#
#------------------------------------------------------------------------
_YIELD_INTERVAL = 350
#------------------------------------------------------------------------

View File

@ -18,10 +18,9 @@
#------------------------------------------------------------------------
#
# modules
# Gtk modules
#
#------------------------------------------------------------------------
from gi.repository import Gtk
#------------------------------------------------------------------------
@ -32,17 +31,15 @@ from gi.repository import Gtk
from gramps.gen.const import URL_WIKISTRING, URL_MANUAL_PAGE, URL_HOMEPAGE
from gramps.gen.plug import Gramplet
from gramps.gui.widgets.styledtexteditor import StyledTextEditor
from gramps.gui.widgets import SimpleButton
from gramps.gen.lib import StyledText, StyledTextTag, StyledTextTagType
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
#------------------------------------------------------------------------
#
# functions
# Functions
#
#------------------------------------------------------------------------
def st(text):
""" Return text as styled text
"""
@ -51,15 +48,13 @@ def st(text):
def boldst(text):
""" Return text as bold styled text
"""
tags = [StyledTextTag(StyledTextTagType.BOLD, True,
[(0, len(text))])]
tags = [StyledTextTag(StyledTextTagType.BOLD, True, [(0, len(text))])]
return StyledText(text, tags)
def linkst(text, url):
""" Return text as link styled text
"""
tags = [StyledTextTag(StyledTextTagType.LINK, url,
[(0, len(text))])]
tags = [StyledTextTag(StyledTextTagType.LINK, url, [(0, len(text))])]
return StyledText(text, tags)
#------------------------------------------------------------------------
@ -85,19 +80,20 @@ class WelcomeGramplet(Gramplet):
top = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
scrolledwindow = Gtk.ScrolledWindow()
scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC,
Gtk.PolicyType.AUTOMATIC)
self.texteditor = StyledTextEditor()
self.texteditor.set_editable(False)
self.texteditor.set_wrap_mode(Gtk.WrapMode.WORD)
scrolledwindow.add(self.texteditor)
self.set_text()
self.display_text()
top.pack_start(scrolledwindow, True, True, 0)
top.show_all()
return top
def set_text(self):
def display_text(self):
"""
Display the welcome text.
"""
@ -112,14 +108,15 @@ class WelcomeGramplet(Gramplet):
'%(gramps_wiki_url)sStart_with_Genealogy' %
{'gramps_wiki_url': URL_WIKISTRING}) + '\n'
welcome += linkst(_('Gramps online manual'),
URL_WIKISTRING + URL_MANUAL_PAGE + _('locale_suffix|')) + '\n'
URL_WIKISTRING + URL_MANUAL_PAGE +
_('locale_suffix|')) + '\n'
welcome += linkst(_('Ask questions on gramps-users mailing list'),
'%(gramps_home_url)scontact/' %
{'gramps_home_url': URL_HOMEPAGE}) + '\n\n'
welcome += boldst(_('Who makes Gramps?')) + '\n\n' + _(
'Gramps is created by genealogists for genealogists, organized in the'
' Gramps Project.'
'Gramps is created by genealogists for genealogists, organized in'
' the Gramps Project.'
' Gramps is an Open Source Software package, which means you are '
'free to make copies and distribute it to anyone you like. It\'s '
'developed and maintained by a worldwide team of volunteers whose'
@ -128,17 +125,18 @@ class WelcomeGramplet(Gramplet):
'The first thing you must do is to create a new Family Tree. To '
'create a new Family Tree (sometimes called \'database\') select '
'"Family Trees" from the menu, pick "Manage Family Trees", press '
'"New" and name your Family Tree. For more details, please read the '
'information at the links above\n\n')
'"New" and name your Family Tree. For more details, please read '
'the information at the links above\n\n')
welcome += boldst(_('Dashboard View')) + '\n\n' + _(
'You are currently reading from the "Dashboard" view, where you can'
' add your own gramplets. You can also add gramplets to any view by'
' adding a sidebar and/or bottombar, and right-clicking to the right'
' of the tab.\n\n'
'You can click the configuration icon in the toolbar to add additional'
' columns, while right-click on the background allows to add gramplets.'
' You can also drag the Properties button to reposition the gramplet '
' on this page, and detach the gramplet to float above Gramps.'
' adding a sidebar and/or bottombar, and right-clicking to the'
' right of the tab.\n\n'
'You can click the configuration icon in the toolbar to add'
' additional columns, while right-click on the background allows to'
' add gramplets. You can also drag the Properties button to'
' reposition the gramplet on this page, and detach the gramplet to'
' float above Gramps.'
)
self.texteditor.set_text(welcome)

View File

@ -227,7 +227,7 @@ class WhatNextGramplet(Gramplet):
spouses = []
spouses_queue = []
while (ancestors or families):
while ancestors or families:
# (Other) families of parents
for ancestor_group in ancestors_queue.pop(0):
new_family_group = []
@ -416,9 +416,7 @@ class WhatNextGramplet(Gramplet):
if not name2:
name2 = _("(person with unknown name)")
name = _("%(name1)s and %(name2)s") % {
'name1': name1,
'name2': name2}
name = _("%(name1)s and %(name2)s") % {'name1': name1, 'name2': name2}
has_marriage = False
@ -463,9 +461,7 @@ class WhatNextGramplet(Gramplet):
if not name2:
name2 = _("(person with unknown name)")
name = _("%(name1)s and %(name2)s") % {
'name1': name1,
'name2': name2}
name = _("%(name1)s and %(name2)s") % {'name1': name1, 'name2': name2}
if self.__family_complete_handle is not None and \
self.__family_complete_handle not in family.get_tag_list():