本文整理汇总了Python中gramps.gen.lib.Note.set_styledtext方法的典型用法代码示例。如果您正苦于以下问题:Python Note.set_styledtext方法的具体用法?Python Note.set_styledtext怎么用?Python Note.set_styledtext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gramps.gen.lib.Note
的用法示例。
在下文中一共展示了Note.set_styledtext方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_note
# 需要导入模块: from gramps.gen.lib import Note [as 别名]
# 或者: from gramps.gen.lib.Note import set_styledtext [as 别名]
def create_note(self, place, data, trans):
new_note = Note()
tag = StyledTextTag(StyledTextTagType.FONTFACE, 'Monospace',
[(0, len(data))])
text = StyledText(data, [tag])
new_note.set_styledtext(text)
note_type = NoteType()
note_type.set((NoteType.CUSTOM, _("Place titles")))
new_note.set_type(note_type)
handle = self.db.add_note(new_note, trans)
place.add_note(handle)
示例2: find_or_make_source
# 需要导入模块: from gramps.gen.lib import Note [as 别名]
# 或者: from gramps.gen.lib.Note import set_styledtext [as 别名]
def find_or_make_source(self):
""" Find or create a source.
returns handle to source."""
for hndl in self.dbstate.db.get_source_handles():
if self.dbstate.db.get_raw_source_data(hndl)[2] == 'GeoNames':
return hndl
# No source found, lets add one with associated repo and note
repo = Repository()
repo.set_name("www.geonames.org")
rtype = RepositoryType(RepositoryType.WEBSITE)
repo.set_type(rtype)
url = Url()
url.set_path('http://www.geonames.org/')
url.set_description(_('GeoNames web site'))
url.set_type(UrlType(UrlType.WEB_HOME))
repo.add_url(url)
url = Url()
url.set_path('[email protected]')
url.set_description(_('GeoNames author'))
url.set_type(UrlType(UrlType.EMAIL))
repo.add_url(url)
note_txt = StyledText(_(
'GeoNames was founded by Marc Wick. You can reach him at '))
note_txt += StyledText('[email protected]' + '\n')
note_txt += StyledText(_(
'GeoNames is a project of Unxos GmbH, Weingartenstrasse 8,'
' 8708 Männedorf, Switzerland.\nThis work is licensed under a '))
note_txt += linkst(
_('Creative Commons Attribution 3.0 License'),
'https://creativecommons.org/licenses/by/3.0/legalcode')
new_note = Note()
new_note.set_styledtext(note_txt)
new_note.set_type(NoteType.REPO)
src = Source()
src.title = 'GeoNames'
src.author = 'Marc Wick'
repo_ref = RepoRef()
mtype = SourceMediaType(SourceMediaType.ELECTRONIC)
repo_ref.set_media_type(mtype)
with DbTxn(_("Add Souce/Repo/Note (%s)") % "GeoNames",
self.dbstate.db) as trans:
self.dbstate.db.add_note(new_note, trans)
repo.add_note(new_note.get_handle())
self.dbstate.db.add_repository(repo, trans)
repo_ref.set_reference_handle(repo.handle)
src.add_repo_reference(repo_ref)
self.dbstate.db.add_source(src, trans)
return src.handle
示例3: NoteGramplet
# 需要导入模块: from gramps.gen.lib import Note [as 别名]
# 或者: from gramps.gen.lib.Note import set_styledtext [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