本文整理汇总了Python中gramps.gen.lib.Note.set_type方法的典型用法代码示例。如果您正苦于以下问题:Python Note.set_type方法的具体用法?Python Note.set_type怎么用?Python Note.set_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gramps.gen.lib.Note
的用法示例。
在下文中一共展示了Note.set_type方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: empty_object
# 需要导入模块: from gramps.gen.lib import Note [as 别名]
# 或者: from gramps.gen.lib.Note import set_type [as 别名]
def empty_object(self):
"""Return an empty Note object for comparison for changes.
It is used by the base class L{EditPrimary}.
"""
empty_note = Note();
if self.extratype:
empty_note.set_type(self.extratype[0])
return empty_note
示例2: new_clicked
# 需要导入模块: from gramps.gen.lib import Note [as 别名]
# 或者: from gramps.gen.lib.Note import set_type [as 别名]
def new_clicked(self, obj):
"""
Create a new To Do note.
"""
from gramps.gui.editors import EditNote
note = Note()
note.set_type(NoteType.TODO)
try:
EditNote(self.gui.dbstate, self.gui.uistate, [], note)
except AttributeError:
pass
示例3: create_note
# 需要导入模块: from gramps.gen.lib import Note [as 别名]
# 或者: from gramps.gen.lib.Note import set_type [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)
示例4: call_editor
# 需要导入模块: from gramps.gen.lib import Note [as 别名]
# 或者: from gramps.gen.lib.Note import set_type [as 别名]
def call_editor(self, obj=None):
if obj is None:
note = Note()
note.set_type(self.get_notetype())
func = self.obj_added
else:
note = obj
func = self.after_edit
try:
EditNote(self.dbstate, self.uistate, self.track,
note, func)
except WindowActiveError:
pass
示例5: find_or_make_source
# 需要导入模块: from gramps.gen.lib import Note [as 别名]
# 或者: from gramps.gen.lib.Note import set_type [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
示例6: add_button_clicked
# 需要导入模块: from gramps.gen.lib import Note [as 别名]
# 或者: from gramps.gen.lib.Note import set_type [as 别名]
def add_button_clicked(self, obj):
"""
Create a new Note instance and call the EditNote editor with the new
note.
Called when the Add button is clicked.
If the window already exists (WindowActiveError), we ignore it.
This prevents the dialog from coming up twice on the same object.
"""
note = Note()
if self.notetype :
note.set_type(self.notetype)
try:
from .. import EditNote
EditNote(self.dbstate, self.uistate, self.track,
note, self.add_callback,
self.callertitle, extratype = [self.notetype])
except WindowActiveError:
pass
示例7: new_clicked
# 需要导入模块: from gramps.gen.lib import Note [as 别名]
# 或者: from gramps.gen.lib.Note import set_type [as 别名]
def new_clicked(self, obj):
"""
Create a new To Do note.
"""
nav_type = self.uistate.viewmanager.active_page.navigation_type()
active_handle = self.get_active(nav_type)
if active_handle:
from gramps.gui.editors import EditNote
note = Note()
note.set_type(NoteType.TODO)
try:
EditNote(self.gui.dbstate, self.gui.uistate, [], note, self.created)
except WindowActiveError:
pass
else:
WarningDialog(_("No active object"),
_("First select the object to which you want to attach a note")
+ _(":") + _(nav_type),
parent=self.uistate.window)
示例8: NoteGramplet
# 需要导入模块: from gramps.gen.lib import Note [as 别名]
# 或者: from gramps.gen.lib.Note import set_type [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
示例9: NoteSidebarFilter
# 需要导入模块: from gramps.gen.lib import Note [as 别名]
# 或者: from gramps.gen.lib.Note import set_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([]))
#.........这里部分代码省略.........