本文整理汇总了Python中gramps.gen.lib.Tag.set_priority方法的典型用法代码示例。如果您正苦于以下问题:Python Tag.set_priority方法的具体用法?Python Tag.set_priority怎么用?Python Tag.set_priority使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gramps.gen.lib.Tag
的用法示例。
在下文中一共展示了Tag.set_priority方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cb_new_tag
# 需要导入模块: from gramps.gen.lib import Tag [as 别名]
# 或者: from gramps.gen.lib.Tag import set_priority [as 别名]
def cb_new_tag(self, action):
"""
Create a new tag and tag the selected objects.
"""
tag = Tag()
tag.set_priority(self.db.get_number_of_tags())
EditTag(self.db, self.uistate, [], tag)
if tag.get_handle():
self.tag_selected_rows(tag.get_handle())
示例2: cb_add_clicked
# 需要导入模块: from gramps.gen.lib import Tag [as 别名]
# 或者: from gramps.gen.lib.Tag import set_priority [as 别名]
def cb_add_clicked(self, button, top):
"""
Create a new tag.
"""
tag = Tag()
tag.set_priority(self.db.get_number_of_tags())
EditTag(self.db, self.uistate, self.track, tag)
if tag.get_handle():
self.namemodel.add((tag.get_priority(),
tag.get_handle(),
tag.get_name(),
tag.get_color()))
示例3: cb_add_clicked
# 需要导入模块: from gramps.gen.lib import Tag [as 别名]
# 或者: from gramps.gen.lib.Tag import set_priority [as 别名]
def cb_add_clicked(self, button, top):
"""
Create a new tag.
"""
tag = Tag()
tag.set_priority(self.db.get_number_of_tags())
edit_dialog = EditTag(self.db, top, tag)
edit_dialog.run()
if tag.get_handle():
self.namemodel.add((tag.get_priority(),
tag.get_handle(),
tag.get_name(),
tag.get_color()))
示例4: create_tag
# 需要导入模块: from gramps.gen.lib import Tag [as 别名]
# 或者: from gramps.gen.lib.Tag import set_priority [as 别名]
def create_tag(self, tag_name, tag_color):
"""
Create a tag if it doesn't already exist.
"""
tag = self.db.get_tag_from_name(tag_name)
if tag is None:
tag = Tag()
tag.set_name(tag_name)
if tag_color is not None:
tag.set_color(tag_color)
tag.set_priority(self.db.get_number_of_tags())
tag_handle = self.db.add_tag(tag, self.trans)
else:
tag_handle = tag.get_handle()
return tag_handle
示例5: on_ok_clicked
# 需要导入模块: from gramps.gen.lib import Tag [as 别名]
# 或者: from gramps.gen.lib.Tag import set_priority [as 别名]
def on_ok_clicked(self, obj):
clean = self.clear_button.get_active()
copy = self.copy_button.get_active()
tag = self.tag_button.get_active()
if not (copy or clean or tag):
return
self.db.disable_signals()
if tag:
tag_name = _('Legacy place')
# start the db transaction
with DbTxn("Tag for place titles", self.db) as self.tag_trans:
mark = self.db.get_tag_from_name(tag_name)
if not mark:
# create the tag if it doesn't already exist
mark = Tag()
mark.set_name(tag_name)
mark.set_priority(self.db.get_number_of_tags())
tag_handle = self.db.add_tag(mark, self.tag_trans)
else:
tag_handle = mark.get_handle()
with DbTxn(_("Modify Place titles"), self.db, batch=True) as trans:
for row in self.model:
if row[1] == True:
place = self.db.get_place_from_handle(row[0])
if copy:
self.create_note(place, row[2], trans)
if clean:
place.set_title("")
if tag:
place.add_tag(tag_handle)
self.db.commit_place(place, trans)
self.db.enable_signals()
self.db.request_rebuild()
self.close()
示例6: applyTagClicked
# 需要导入模块: from gramps.gen.lib import Tag [as 别名]
# 或者: from gramps.gen.lib.Tag import set_priority [as 别名]
def applyTagClicked(self, button) :
progress = None
rows = self.treeSelection.count_selected_rows()
tag_name = str(self.tagcombo.get_active_text())
# start the db transaction
with DbTxn("Tag not related", self.db) as transaction:
tag = self.db.get_tag_from_name(tag_name)
if not tag:
# create the tag if it doesn't already exist
tag = Tag()
tag.set_name(tag_name)
tag.set_priority(self.db.get_number_of_tags())
tag_handle = self.db.add_tag(tag, transaction)
else:
tag_handle = tag.get_handle()
# if more than 1 person is selected, use a progress indicator
if rows > 1:
progress = ProgressMeter(self.title,_('Starting'),
parent=self.window)
progress.set_pass(
# translators: leave all/any {...} untranslated
#TRANS: no singular form needed, as rows is always > 1
ngettext("Setting tag for {number_of} person",
"Setting tag for {number_of} people",
rows).format(number_of=rows),
rows)
# iterate through all of the selected rows
(model, paths) = self.treeSelection.get_selected_rows()
for path in paths:
if progress:
progress.step()
# for the current row, get the GID and the person from the database
iter = self.model.get_iter(path)
personGid = self.model.get_value(iter, 1)
person = self.db.get_person_from_gramps_id(personGid)
# add the tag to the person
person.add_tag(tag_handle)
# save this change
self.db.commit_person(person, transaction)
# refresh the tags column
self.treeView.set_model(None)
for path in paths:
iter = self.model.get_iter(path)
personGid = self.model.get_value(iter, 1)
person = self.db.get_person_from_gramps_id(personGid)
self.model.set_value(iter, 3, self.get_tag_list(person))
self.treeView.set_model(self.model)
self.treeView.expand_all()
if progress:
progress.close()