本文整理汇总了Python中gramps.gen.lib.Event.get_type方法的典型用法代码示例。如果您正苦于以下问题:Python Event.get_type方法的具体用法?Python Event.get_type怎么用?Python Event.get_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gramps.gen.lib.Event
的用法示例。
在下文中一共展示了Event.get_type方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EventSidebarFilter
# 需要导入模块: from gramps.gen.lib import Event [as 别名]
# 或者: from gramps.gen.lib.Event import get_type [as 别名]
class EventSidebarFilter(SidebarFilter):
def __init__(self, dbstate, uistate, clicked):
self.clicked_func = clicked
self.filter_id = widgets.BasicEntry()
self.filter_desc = widgets.BasicEntry()
self.filter_event = Event()
self.filter_event.set_type((EventType.CUSTOM, ''))
self.etype = Gtk.ComboBox(has_entry=True)
self.custom_types = dbstate.db.get_event_types()
self.event_menu = widgets.MonitoredDataType(
self.etype,
self.filter_event.set_type,
self.filter_event.get_type,
custom_values=self.custom_types)
self.filter_mainparts = widgets.BasicEntry()
self.filter_date = widgets.DateEntry(uistate, [])
self.filter_place = widgets.BasicEntry()
self.filter_note = widgets.BasicEntry()
self.filter_regex = Gtk.CheckButton(label=_('Use regular expressions'))
self.tag = Gtk.ComboBox()
self.generic = Gtk.ComboBox()
SidebarFilter.__init__(self, dbstate, uistate, "Event")
def create_widget(self):
cell = Gtk.CellRendererText()
cell.set_property('width', self._FILTER_WIDTH)
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
self.generic.pack_start(cell, True)
self.generic.add_attribute(cell, 'text', 0)
self.on_filters_changed('Event')
cell = Gtk.CellRendererText()
cell.set_property('width', self._FILTER_WIDTH)
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
self.tag.pack_start(cell, True)
self.tag.add_attribute(cell, 'text', 0)
self.etype.get_child().set_width_chars(5)
self.add_text_entry(_('ID'), self.filter_id)
self.add_text_entry(_('Description'), self.filter_desc)
self.add_entry(_('Type'), self.etype)
self.add_text_entry(_('Participants'), self.filter_mainparts)
self.add_text_entry(_('Date'), self.filter_date)
self.add_text_entry(_('Place'), self.filter_place)
self.add_text_entry(_('Note'), self.filter_note)
self.add_entry(_('Tag'), self.tag)
self.add_filter_entry(_('Custom filter'), self.generic)
self.add_regex_entry(self.filter_regex)
def clear(self, obj):
self.filter_id.set_text('')
self.filter_desc.set_text('')
self.filter_mainparts.set_text('')
self.filter_date.set_text('')
self.filter_place.set_text('')
self.filter_note.set_text('')
self.etype.get_child().set_text('')
self.tag.set_active(0)
self.generic.set_active(0)
def get_filter(self):
gid = str(self.filter_id.get_text()).strip()
desc = str(self.filter_desc.get_text()).strip()
mainparts = str(self.filter_mainparts.get_text()).strip()
date = str(self.filter_date.get_text()).strip()
place = str(self.filter_place.get_text()).strip()
note = str(self.filter_note.get_text()).strip()
regex = self.filter_regex.get_active()
tag = self.tag.get_active() > 0
generic = self.generic.get_active() > 0
etype = self.filter_event.get_type().xml_str()
empty = not (gid or desc or mainparts or date or place or note
or etype or regex or tag or generic)
if empty:
generic_filter = None
else:
generic_filter = GenericEventFilter()
if gid:
rule = RegExpIdOf([gid], use_regex=regex)
generic_filter.add_rule(rule)
rule = HasEvent([etype, date, place, desc, mainparts],
use_regex=regex)
generic_filter.add_rule(rule)
if note:
rule = HasNoteRegexp([note], use_regex=regex)
generic_filter.add_rule(rule)
# check the Tag
if tag:
model = self.tag.get_model()
#.........这里部分代码省略.........
示例2: FamilySidebarFilter
# 需要导入模块: from gramps.gen.lib import Event [as 别名]
# 或者: from gramps.gen.lib.Event import get_type [as 别名]
class FamilySidebarFilter(SidebarFilter):
def __init__(self, dbstate, uistate, clicked):
self.clicked_func = clicked
self.filter_id = widgets.BasicEntry()
self.filter_father = widgets.BasicEntry()
self.filter_mother = widgets.BasicEntry()
self.filter_child = widgets.BasicEntry()
self.filter_event = Event()
self.filter_event.set_type((EventType.CUSTOM, ''))
self.etype = Gtk.ComboBox(has_entry=True)
self.family_stub = Family()
self.family_stub.set_relationship((FamilyRelType.CUSTOM, ''))
self.rtype = Gtk.ComboBox(has_entry=True)
self.event_menu = widgets.MonitoredDataType(
self.etype,
self.filter_event.set_type,
self.filter_event.get_type)
self.rel_menu = widgets.MonitoredDataType(
self.rtype,
self.family_stub.set_relationship,
self.family_stub.get_relationship)
self.filter_note = widgets.BasicEntry()
self.filter_regex = Gtk.CheckButton(label=_('Use regular expressions'))
self.tag = Gtk.ComboBox()
self.generic = Gtk.ComboBox()
SidebarFilter.__init__(self, dbstate, uistate, "Family")
def create_widget(self):
cell = Gtk.CellRendererText()
cell.set_property('width', self._FILTER_WIDTH)
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
self.generic.pack_start(cell, True)
self.generic.add_attribute(cell, 'text', 0)
self.on_filters_changed('Family')
cell = Gtk.CellRendererText()
cell.set_property('width', self._FILTER_WIDTH)
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
self.tag.pack_start(cell, True)
self.tag.add_attribute(cell, 'text', 0)
self.etype.get_child().set_width_chars(5)
self.rtype.get_child().set_width_chars(5)
self.add_text_entry(_('ID'), self.filter_id)
self.add_text_entry(_('Father'), self.filter_father)
self.add_text_entry(_('Mother'), self.filter_mother)
self.add_text_entry(_('Child'), self.filter_child)
self.add_entry(_('Relationship'), self.rtype)
self.add_entry(_('Family Event'), self.etype)
self.add_text_entry(_('Family Note'), self.filter_note)
self.add_entry(_('Tag'), self.tag)
self.add_filter_entry(_('Custom filter'), self.generic)
self.add_regex_entry(self.filter_regex)
def clear(self, obj):
self.filter_id.set_text('')
self.filter_father.set_text('')
self.filter_mother.set_text('')
self.filter_child.set_text('')
self.filter_note.set_text('')
self.etype.get_child().set_text('')
self.rtype.get_child().set_text('')
self.tag.set_active(0)
self.generic.set_active(0)
def get_filter(self):
gid = str(self.filter_id.get_text()).strip()
father = str(self.filter_father.get_text()).strip()
mother = str(self.filter_mother.get_text()).strip()
child = str(self.filter_child.get_text()).strip()
note = str(self.filter_note.get_text()).strip()
etype = self.filter_event.get_type().xml_str()
rtype = self.family_stub.get_relationship().xml_str()
regex = self.filter_regex.get_active()
tag = self.tag.get_active() > 0
generic = self.generic.get_active() > 0
empty = not (gid or father or mother or child or note
or regex or etype or rtype or tag or generic)
if empty:
generic_filter = None
else:
generic_filter = GenericFamilyFilter()
if gid:
rule = RegExpIdOf([gid], use_regex=regex)
generic_filter.add_rule(rule)
if father:
rule = RegExpFatherName([father], use_regex=regex)
generic_filter.add_rule(rule)
#.........这里部分代码省略.........
示例3: PersonSidebarFilter
# 需要导入模块: from gramps.gen.lib import Event [as 别名]
# 或者: from gramps.gen.lib.Event import get_type [as 别名]
class PersonSidebarFilter(SidebarFilter):
def __init__(self, dbstate, uistate, clicked):
self.clicked_func = clicked
self.filter_name = widgets.BasicEntry()
self.filter_id = widgets.BasicEntry()
self.filter_birth = widgets.DateEntry(uistate, [])
self.filter_death = widgets.DateEntry(uistate, [])
self.filter_event = Event()
self.filter_event.set_type((EventType.CUSTOM, ''))
self.etype = Gtk.ComboBox(has_entry=True)
if dbstate.is_open():
self.custom_types = dbstate.db.get_event_types()
else:
self.custom_types = []
self.event_menu = widgets.MonitoredDataType(
self.etype,
self.filter_event.set_type,
self.filter_event.get_type,
custom_values=self.custom_types)
self.filter_note = widgets.BasicEntry()
self.filter_gender = Gtk.ComboBoxText()
list(map(self.filter_gender.append_text,
[ _('any'), _('male'), _('female'), _('unknown') ]))
self.filter_gender.set_active(0)
self.filter_regex = Gtk.CheckButton(label=_('Use regular expressions'))
self.tag = Gtk.ComboBox()
self.generic = Gtk.ComboBox()
SidebarFilter.__init__(self, dbstate, uistate, "Person")
def create_widget(self):
cell = Gtk.CellRendererText()
cell.set_property('width', self._FILTER_WIDTH)
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
self.generic.pack_start(cell, True)
self.generic.add_attribute(cell, 'text', 0)
self.on_filters_changed('Person')
cell = Gtk.CellRendererText()
cell.set_property('width', self._FILTER_WIDTH)
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
self.tag.pack_start(cell, True)
self.tag.add_attribute(cell, 'text', 0)
self.etype.get_child().set_width_chars(5)
exdate1 = Date()
exdate2 = Date()
exdate1.set(Date.QUAL_NONE, Date.MOD_RANGE,
Date.CAL_GREGORIAN, (0, 0, 1800, False,
0, 0, 1900, False))
exdate2.set(Date.QUAL_NONE, Date.MOD_BEFORE,
Date.CAL_GREGORIAN, (0, 0, 1850, False))
msg1 = displayer.display(exdate1)
msg2 = displayer.display(exdate2)
self.add_text_entry(_('Name'), self.filter_name)
self.add_text_entry(_('ID'), self.filter_id)
self.add_entry(_('Gender'), self.filter_gender)
self.add_text_entry(_('Birth date'), self.filter_birth,
_('example: "%(msg1)s" or "%(msg2)s"') % {'msg1':msg1, 'msg2':msg2})
self.add_text_entry(_('Death date'), self.filter_death,
_('example: "%(msg1)s" or "%(msg2)s"') % {'msg1':msg1, 'msg2':msg2})
self.add_entry(_('Event'), self.etype)
self.add_text_entry(_('Note'), self.filter_note)
self.add_entry(_('Tag'), self.tag)
self.add_filter_entry(_('Custom filter'), self.generic)
self.add_regex_entry(self.filter_regex)
def clear(self, obj):
self.filter_name.set_text('')
self.filter_id.set_text('')
self.filter_birth.set_text('')
self.filter_death.set_text('')
self.filter_note.set_text('')
self.filter_gender.set_active(0)
self.etype.get_child().set_text('')
self.tag.set_active(0)
self.generic.set_active(0)
def get_filter(self):
"""
Extracts the text strings from the sidebar, and uses them to build up
a new filter.
"""
# extract text values from the entry widgets
name = extract_text(self.filter_name)
gid = extract_text(self.filter_id)
birth = extract_text(self.filter_birth)
death = extract_text(self.filter_death)
note = extract_text(self.filter_note)
# extract remaining data from the menus
etype = self.filter_event.get_type().xml_str()
#.........这里部分代码省略.........