本文整理汇总了Python中gramps.gen.lib.Note.set_gramps_id方法的典型用法代码示例。如果您正苦于以下问题:Python Note.set_gramps_id方法的具体用法?Python Note.set_gramps_id怎么用?Python Note.set_gramps_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gramps.gen.lib.Note
的用法示例。
在下文中一共展示了Note.set_gramps_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_note
# 需要导入模块: from gramps.gen.lib import Note [as 别名]
# 或者: from gramps.gen.lib.Note import set_gramps_id [as 别名]
def add_note(self, gid, text, trans):
new_note = self.db.get_note_from_gramps_id(gid)
if new_note:
new_note.set(text)
self.db.commit_note(new_note, trans)
msg = _("Add Test Note")
else:
new_note = Note(text)
new_note.set_gramps_id(gid)
self.db.add_note(new_note, trans)
msg = _("Add Test Note")
trans.set_description(msg)
示例2: NoteGramplet
# 需要导入模块: from gramps.gen.lib import Note [as 别名]
# 或者: from gramps.gen.lib.Note import set_gramps_id [as 别名]
#.........这里部分代码省略.........
name = name_displayer.display(active_person)
self.active_person_widget.set_text("<i>%s</i> " % name)
self.active_person_widget.set_use_markup(True)
# Note:
self.note = None
note_list = active_person.get_referenced_note_handles()
for (classname, note_handle) in note_list:
note_obj = self.dbstate.db.get_note_from_handle(note_handle)
if note_obj.get_type() == _("Person Note"):
self.note = note_obj
break
if self.note is None:
self.note = Note()
self.texteditor.set_text(self.note.get_styledtext())
self.flow_changed(self.note.get_format())
# Family button:
family_list = active_person.get_family_handle_list()
if len(family_list) > 0:
self._dirty_family = self.dbstate.db.get_family_from_handle(family_list[0])
self.active_family_edit.show()
self.active_family_label.show()
else:
family_list = active_person.get_parent_family_handle_list()
if len(family_list) > 0:
self._dirty_family = self.dbstate.db.get_family_from_handle(family_list[0])
self.active_family_edit.show()
self.active_family_label.show()
else:
self.clear_data_entry(None)
self.active_person_edit.hide()
self.active_family_edit.hide()
self.active_family_label.hide()
self._dirty = False
def clear_data_entry(self, obj):
self.note_buffer.set_text(StyledText())
self.flow_changed(False)
def db_changed(self):
"""
If person or family changes, the relatives of active person might have
changed
"""
self.connect(self.dbstate.db, 'person-update', self.update)
self.connect(self.dbstate.db, 'note-update', self.update)
self._dirty = False
self._dirty_person = None
self.clear_data_entry(None)
self.texteditor.set_editable(not self.dbstate.db.readonly)
self.update()
def active_changed(self, handle):
self.update()
def mark_dirty(self, obj):
self._dirty = True
def abandon_data_edit(self, obj):
self._dirty = False
self.update()
def edit_callback(self, person):
self._dirty = False
self.update()
def edit_person(self, obj):
from gramps.gui.editors import EditPerson
try:
EditPerson(self.gui.dbstate,
self.gui.uistate, [],
self._dirty_person,
callback=self.edit_callback)
except WindowActiveError:
pass
def edit_family(self, obj):
from gramps.gui.editors import EditFamily
try:
EditFamily(self.gui.dbstate,
self.gui.uistate, [],
self._dirty_family)
except WindowActiveError:
pass
def save_data_edit(self, obj):
if self._dirty:
person = self._dirty_person
text = self.texteditor.get_text()
self.note.set_styledtext(text)
with DbTxn(_("Save Note"), self.dbstate.db) as trans:
if not self.note.get_handle():
self.note.set_type(_("Person Note"))
self.dbstate.db.add_note(self.note, trans)
person.add_note(self.note.get_handle())
self.dbstate.db.commit_person(person, trans)
else:
if not self.note.get_gramps_id():
self.note.set_gramps_id(self.dbstate.db.find_next_note_gramps_id())
self.dbstate.db.commit_note(self.note, trans)
self._dirty = False