本文整理汇总了Python中gramps.gen.lib.Citation.gramps_id方法的典型用法代码示例。如果您正苦于以下问题:Python Citation.gramps_id方法的具体用法?Python Citation.gramps_id怎么用?Python Citation.gramps_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gramps.gen.lib.Citation
的用法示例。
在下文中一共展示了Citation.gramps_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_ok_clicked
# 需要导入模块: from gramps.gen.lib import Citation [as 别名]
# 或者: from gramps.gen.lib.Citation import gramps_id [as 别名]
def on_ok_clicked(self):
"""
Method that is run when you click the OK button. The numbers of sources
and citations are retrieved from the entry box and used to govern the
amount of data generated
"""
num_sources_text = self.sources_entry.get_text()
try:
num_sources = int(num_sources_text)
except:
return
num_citations_text = self.citations_entry.get_text()
num_citations = int(num_citations_text)
self.progress = ProgressMeter(
'Generating data', '', parent=self.uistate.window)
self.progress.set_pass('Generating data',
num_sources*num_citations)
LOG.debug("sources %04d citations %04d" % (num_sources,
num_citations))
source = Source()
citation = Citation()
self.db.disable_signals()
with DbTxn('Populate sources and citations', self.db) as trans:
for i in range(num_sources):
source.gramps_id = None
source.handle = None
source.title = "Source %04d" % (i + 1)
source_handle = self.db.add_source(source, trans)
for j in range(num_citations):
citation.gramps_id = None
citation.handle = None
citation.source_handle = source_handle
citation.page = "Page %04d" % (j + 1)
self.db.add_citation(citation, trans)
self.progress.step()
LOG.debug("sources and citations added")
self.db.enable_signals()
self.db.request_rebuild()
self.progress.close()
self.options.handler.options_dict['sources'] = num_sources
self.options.handler.options_dict['citations'] = num_citations
# Save options
self.options.handler.save_options()