本文整理汇总了Python中gramps.gen.lib.Note.get_type方法的典型用法代码示例。如果您正苦于以下问题:Python Note.get_type方法的具体用法?Python Note.get_type怎么用?Python Note.get_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gramps.gen.lib.Note
的用法示例。
在下文中一共展示了Note.get_type方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: NoteSidebarFilter
# 需要导入模块: from gramps.gen.lib import Note [as 别名]
# 或者: from gramps.gen.lib.Note import get_type [as 别名]
class NoteSidebarFilter(SidebarFilter):
def __init__(self, dbstate, uistate, clicked):
self.clicked_func = clicked
self.filter_id = widgets.BasicEntry()
self.filter_text = widgets.BasicEntry()
self.note = Note()
self.note.set_type((NoteType.CUSTOM,''))
self.ntype = Gtk.ComboBox(has_entry=True)
if dbstate.is_open():
self.custom_types = dbstate.db.get_note_types()
else:
self.custom_types = []
self.event_menu = widgets.MonitoredDataType(
self.ntype,
self.note.set_type,
self.note.get_type,
False, # read-only?
self.custom_types)
self.filter_regex = Gtk.CheckButton(label=_('Use regular expressions'))
self.tag = Gtk.ComboBox()
self.generic = Gtk.ComboBox()
SidebarFilter.__init__(self, dbstate, uistate, "Note")
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('Note')
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.ntype.get_child().set_width_chars(5)
self.add_text_entry(_('ID'), self.filter_id)
self.add_text_entry(_('Text'), self.filter_text)
self.add_entry(_('Type'), self.ntype)
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_text.set_text('')
self.ntype.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()
text = str(self.filter_text.get_text()).strip()
ntype = self.note.get_type().xml_str()
regex = self.filter_regex.get_active()
tag = self.tag.get_active() > 0
gen = self.generic.get_active() > 0
empty = not (gid or text or ntype or regex or tag or gen)
if empty:
generic_filter = None
else:
generic_filter = GenericNoteFilter()
if gid:
rule = RegExpIdOf([gid], use_regex=regex)
generic_filter.add_rule(rule)
rule = HasNote([text, ntype], use_regex=regex)
generic_filter.add_rule(rule)
# check the Tag
if tag:
model = self.tag.get_model()
node = self.tag.get_active_iter()
attr = model.get_value(node, 0)
rule = HasTag([attr])
generic_filter.add_rule(rule)
if self.generic.get_active() != 0:
model = self.generic.get_model()
node = self.generic.get_active_iter()
obj = str(model.get_value(node, 0))
rule = MatchesFilter([obj])
generic_filter.add_rule(rule)
return generic_filter
def on_filters_changed(self, name_space):
if name_space == 'Note':
all_filter = GenericNoteFilter()
all_filter.set_name(_("None"))
all_filter.add_rule(rules.note.AllNotes([]))
#.........这里部分代码省略.........