当前位置: 首页>>代码示例>>Python>>正文


Python Citation.get_handle方法代码示例

本文整理汇总了Python中gramps.gen.lib.Citation.get_handle方法的典型用法代码示例。如果您正苦于以下问题:Python Citation.get_handle方法的具体用法?Python Citation.get_handle怎么用?Python Citation.get_handle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gramps.gen.lib.Citation的用法示例。


在下文中一共展示了Citation.get_handle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_event

# 需要导入模块: from gramps.gen.lib import Citation [as 别名]
# 或者: from gramps.gen.lib.Citation import get_handle [as 别名]
 def create_event(self, description=_("Estimated date"),
                  type=None, date=None, source=None,
                  note_text="", modifier=None):
     event = Event()
     event.set_description(description)
     note = Note()
     note.handle = create_id()
     note.type.set(NoteType.EVENT)
     note.set(note_text)
     self.db.add_note(note, self.trans)
     event.add_note(note.handle)
     if type:
         event.set_type(EventType(type))
     if date:
         if modifier:
             date.set_modifier(modifier)
         date.set_quality(Date.QUAL_ESTIMATED)
         date.set_yr_mon_day(date.get_year(), 0, 0)
         event.set_date_object(date)
     if source:
         citation = Citation()
         citation.set_reference_handle(source.get_handle())
         self.db.add_citation(citation, self.trans)
         event.add_citation(citation.get_handle())
         self.db.commit_source(source, self.trans)
     self.db.add_event(event, self.trans)
     return event
开发者ID:daleathan,项目名称:addons-source,代码行数:29,代码来源:CalculateEstimatedDates.py

示例2: find_and_set_citation

# 需要导入模块: from gramps.gen.lib import Citation [as 别名]
# 或者: from gramps.gen.lib.Citation import get_handle [as 别名]
 def find_and_set_citation(self, obj, source):
     # look for the source in the existing citations for the object
     LOG.debug("find_and_set_citation: looking for source: %s",
               source.get_gramps_id())
     for citation_handle in obj.get_citation_list():
         citation = self.db.get_citation_from_handle(citation_handle)
         LOG.debug("find_and_set_citation: existing citation: %s",
                   citation.get_gramps_id())
         poss_source = self.db.get_source_from_handle(
                                 citation.get_reference_handle())
         LOG.debug("   compare source %s == %s", source.get_gramps_id(),
                   poss_source.get_gramps_id())
         if poss_source.get_handle() == source.get_handle():
             # The source is already cited
             LOG.debug("   source already cited")
             return
     # we couldn't find an appropriate citation, so we have to create one.
     citation = Citation()
     LOG.debug("   creating citation")
     citation.set_reference_handle(source.get_handle())
     self.db.add_citation(citation, self.trans)
     LOG.debug("   created citation, citation %s %s" %
               (citation, citation.get_gramps_id()))
     obj.add_citation(citation.get_handle())
开发者ID:tecknicaltom,项目名称:gramps,代码行数:26,代码来源:importcsv.py

示例3: CensusEditor

# 需要导入模块: from gramps.gen.lib import Citation [as 别名]
# 或者: from gramps.gen.lib.Citation import get_handle [as 别名]
class CensusEditor(ManagedWindow):
    """
    Census Editor.
    """
    def __init__(self, dbstate, uistate, track, event):

        self.dbstate = dbstate
        self.uistate = uistate
        self.track = track
        self.db = dbstate.db
        
        self.event = event
        self.citation = get_census_citation(self.db, self.event)
        if self.citation is None:
            self.citation = Citation()

        ManagedWindow.__init__(self, uistate, track, event)

        self.widgets = {}
        top = self.__create_gui()
        self.set_window(top, None, self.get_menu_title())

        self._config = config.get_manager('census')
        width = self._config.get('interface.census-width')
        height = self._config.get('interface.census-height')
        self.window.resize(width, height)

        self.place_field = PlaceEntry(self.dbstate, self.uistate, self.track,
                                      self.widgets['place_text'],
                                      self.event.set_place_handle,
                                      self.event.get_place_handle,
                                      self.widgets['place_add'],
                                      self.widgets['place_share'])

        self.ref_field = MonitoredEntry(
            self.widgets['ref_entry'], 
            self.citation.set_page, 
            self.citation.get_page, 
            self.db.readonly)

        if self.event.get_handle():
            self.widgets['census_combo'].set_sensitive(False)
            self.__populate_gui(event)
            self.details.populate_gui(event)

    def _add_tab(self, notebook, page):
        notebook.append_page(page, page.get_tab_widget())
        page.label.set_use_underline(True)
        return page

    def get_menu_title(self):
        """
        Get the menu title.
        """
        if self.event.get_handle():
            date = get_date(self.event)
            if not date:
                date = 'unknown'
            dialog_title = _('Census: %s')  % date
        else:
            dialog_title = _('New Census')
        return dialog_title

    def build_menu_names(self, event):
        """
        Build menu names. Overrides method in ManagedWindow.
        """
        return (_('Edit Census'), self.get_menu_title())

    def __create_gui(self):
        """
        Create and display the GUI components of the editor.
        """
        root = Gtk.Window(type=Gtk.WindowType.TOPLEVEL)
        root.set_transient_for(self.uistate.window)

        vbox = Gtk.VBox()

        tab = Gtk.Table(4, 4, False)
        tab.set_row_spacings(10)
        tab.set_col_spacings(10)

        census_label = Gtk.Label(_("Source:"))
        census_label.set_alignment(0.0, 0.5)
        tab.attach(census_label, 0, 1, 0, 1,
                   xoptions=Gtk.AttachOptions.FILL, xpadding=10)
        
        liststore = Gtk.ListStore(str, str, str)
        for row in get_census_sources(self.db):
            liststore.append([row[0].decode(), row[1], row[2]])

        census_combo = Gtk.ComboBox()
        census_combo.set_model(liststore)
        cell = Gtk.CellRendererText()
        census_combo.pack_start(cell, True)
        census_combo.add_attribute(cell, 'text', 1)
        #cell = Gtk.CellRendererText()
        #census_combo.pack_start(cell, True)
        #census_combo.add_attribute(cell, 'text', 2)
        census_combo.connect('changed', self.__census_changed)
#.........这里部分代码省略.........
开发者ID:SNoiraud,项目名称:addons-source,代码行数:103,代码来源:CensusGramplet.py


注:本文中的gramps.gen.lib.Citation.get_handle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。